pieru
TypeScript icon, indicating that this package has built-in type declarations

2.1.0 • Public • Published

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 });

Package Sidebar

Install

npm i pieru

Weekly Downloads

1

Version

2.1.0

License

MIT

Unpacked Size

8.87 kB

Total Files

7

Last publish

Collaborators

  • rauli