Convert RQL into MongoDB queries
var mongoRql = require('mongo-rql'),
Query = require('rql/query').Query,
color = 'yellow',
query = new Query().eq('color', color).sort('-size', 'price'),
mongoQuery = mongoRql(query),
cursor = db.collection.find(mongoQuery.criteria, {
skip: mongoQuery.skip,
limit: mongoQuery.limit,
fields: mongoQuery.projection,
sort: mongoQuery.sort
});
cursor.toArray(function (err, docs) {
// ...
});
With npm do:
npm install mongo-query
New BSD License. All code is developed under the terms of the Dojo Foundation CLA.
© 2014 Ben Hockey