MongoDB query through URL
Pass MongoDB query through URL query string.
Contributors
Installation
With npm do:
$ npm install mongodb-querystring
Tests
Use mocha to run the tests.
$ npm install mocha
$ mocha test
API Documentation
stringify(input : Object, [separator : String]) : String
Converts query
to a URL query string.
var mqs = ; var qry = "$query" : "age" : "$gte" : 1976 11 14 "$or": "cuisine": "Italian" "address.zipcode": "10075" "$limit" : 20 "$orderby" : "age" : -1 "posts": 1 ; console
Output:
'$query[age][$gte]=219366000000^D&$query[$or][0][cuisine]=Italian&$query[$or][1][address.zipcode]=10075&$limit=20^N&$orderby[age]=-1^N&$orderby[posts]=1^N'
parse(input : String) : Object
parse(input : Object) : Object
Parse input
to convert to an query.
var mqs = ; var qry = '$query[type][$in][0]=food&$query[type][$in][1]=snacks'; consoledirmqs;
Output:
{ '$query': { type: { '$in': [ 'food', 'snacks' ] } } }
create(input : String) : Object
create(input : Object) : Object
Parse input
to convert to an Object query.
var mqs = ; var qry = mqs; console; console;