2.1.0 • Published 4 months ago

pieru v2.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

pieru 💨

github coveralls npm

MongoDB query compatible object match.

Installation

$ npm install pieru

Usage

import { match } from 'pieru';

const query = {
  name: { $exists: true },
  qty: { $gt: 3 },
  $and: [
    { price: { $lt: 100 } },
    { price: { $gt: 50 } },
  ],
};

match({ name: 'example', qty: 10, price: 65.10 }, query); // -> true
match({ name: 'bla', qty: 10, price: 30.10 }, query);     // -> false

Please check out the query selector section in the MongoDB documentation.

Supported operators

  • All comparison operators
  • All logical operators
  • All element operators except $type
  • All JavaScript operators
  • All array operators

The following operators are currently not supported:

  • All geospatial operators
  • $type operator

The $where operator is supported but disabled by default (security).

const isMatch = match(obj, query, { $where: true });
2.1.0

4 months ago

2.0.0

4 months ago

1.0.0

4 months ago