File: README.md

Recommend this page to a friend!
  Classes of Jonathan Gotti   Mongo Filter   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: Mongo Filter
Filter collection elements with mongoQuery syntax
Author: By
Last change: Update of README.md
Date: 2 years ago
Size: 1,096 bytes
 

Contents

Class file image Download

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_