README
MongoDB QueryString Parser
Accept MongoDB query parameters through URI queries safe and easy. This is useful when building an API and accepting various user specificed queries.
Features
- Aliased query parameters
- Blacklisted query parameters
- Whitelisted query parameters
- Basic operators
$eq
$gt
$gte
$lt
$lte
$ne
$in
$nin
$exists
$regex
- Parse string integers and floats to numbers
- Parse string boolean to ture/false booleans
operation | query string | query object |
---|---|---|
equal | ?foo=bar |
{ foo: "bar" } |
unequal | ?foo=!bar |
{ foo: { $ne: "bar" }} |
exists | ?foo= |
{ foo: { $exists: true }} |
not exists | ?foo=! |
{ foo: { $exists: false }} |
greater than | ?foo=>10 |
{ foo: { $gt: 10 }} |
less than | ?foo=<10 |
{ foo: { $lt: 10 }} |
greater than or equal to | ?foo=>=10 |
{ foo: { $gte: 10 }} |
less than or equal to | ?foo=<=10 |
{ foo: { $lte: 10 }} |
starts with | ?foo=^bar |
{ foo: { $regex: "^bar", $options: "i" }} |
ends with | ?foo=$bar |
{ foo: { $regex: "bar |