sequelize-where

Pure JS implementation of the sequelize query language (where)

Usage no npm install needed!

<script type="module">
  import sequelizeWhere from 'https://cdn.skypack.dev/sequelize-where';
</script>

README

sequelize-where NPM version Downloads Build Status

Simple query language for filtering objects. Pure JS implementation of the where part of queries from Sequelize.

Install

npm install sequelize-where --save

Usage

import filter from 'sequelize-where'

// filter takes a query object and returns a function
// the filter function returned takes one object argument - the input data
const fn = filter({
  $or: [
    { a: 'c' },
    { a: 'd' },
    { b: { $in: [ 'd', 'e', 'f' ] } }
  ]
})

console.log(fn({ a: 'c' })) // true
console.log(fn({ a: 'd' })) // true
console.log(fn({ a: 'f' })) // false
console.log(fn({ a: 'f', b: 'e' })) // true