npm

Need private packages and team management tools?Check out npm Orgs. »

monjo

1.2.1 • Public • Published

monjo

mongoDB inspired JSON filters for JS

Usage

const compileFilter = require('monjo');
const query = {
  name: 'Foo Bar',
  age: {
    $gt: 5,
  },
  hobbies: {
    $elemMatch: {
      $not: {
        name: {
          $eq: 'music',
        },
      },
    },
  },
};
const filter = compileFilter(query);
const users = getUsers();
for (let validUser of users.filter(filter)) {
  // do stuff
}

Supported Operators

Custom filters

Filters (nested, or otherwise) may be funtions that accept values and return a boolean-like value.

const compileFilter = require('monjo');
const query = {
  age(age) {
    return age % 10 === 0;
  },
};
const filter = compileFilter(query);
const users = getUsers();
for (let validUser of users.filter(filter)) {
  // do stuff
}

install

npm i monjo

Downloadsweekly downloads

0

version

1.2.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability