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

Readme

Keywords

Package Sidebar

Install

npm i uniql-mongodb

Weekly Downloads

6

Version

0.1.0

License

MIT

Last publish

Collaborators

  • andyburke