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

uniql-mongodb

0.1.0 • Public • Published

UniQL-MongoDB

This generates MongoDB queries based on UniQL ASTs.

Example

var parse = require( 'uniql' );
var mongoCompile = require( 'uniql-mongodb' );
 
var ast = parse( '( height <= 20 or ( favorites.color == "green" and height != 25 ) ) and firstname ~= "o.+"' );
var mongoQuery = mongoCompile( ast );
console.log( util.inspect( mongoQuery, { depth: null } ) );

Resulting query:

{ '$or': 
   [ { height: { '$lte': 20 } },
     { 'favorites.color': 'green', height: { '$ne': 25 } } ],
  firstname: { '$regex': 'o.+' } }

License

MIT

Install

npm i uniql-mongodb

DownloadsWeekly Downloads

2

Version

0.1.0

License

MIT

Last publish

Collaborators

  • avatar