Skip to content

honeinc/uniql-mongodb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Produces MongoDB queries from UniQL ASTs.

Resources

License

Stars

Watchers

Forks

Packages

No packages published