2.0.0 • Published 7 years ago

mongofilter v2.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

mongofilter

Filtering elements in collection based on json filters with a mongoQuery like syntax Build Status

Basic usage:

var filter = mongofilter({name:{$like: '%test%'}, age:12});
// filtering a complete collection
filter.filter(collection);
// or alternatively
collection.filter(filter);

// check a single item match against given filter
filter.filterItem(item); // return true or false

// also you can call 'and' or 'or' on the predicate directly:
filter.and({prop:val}).filter(collection);
filter.or({prop:val}).filter(collection);

Comparison operators

Greater than: $gt

Greater Equal than: $gte

Less than: $lt

Less Equal than: $lte

Strict equality: $eq

Strict inequality: $ne

Text matching operators

Like: $like

Not like: $nlike

RegExp: $regex

Subset operator

In: $in

Not in: $nin

Logical operators

And: $and

Or: $or

Nor: $nor

Not: $not