Closed brianjd closed 8 years ago
Good suggestion @brianjd, this project should be better documented. In the mean time, you could look at the test suite and the project which this library was initially created for: https://github.com/Turistforeningen/Turbasen/blob/master/coffee/collection.litcoffee
@Starefossen Thanks,that's exactly what I did to figure out how to use the built-in custom queries (ie. bbox). I will checkout the other project as well. When I have a few more free cycles, I will also try my hand at documentation. Also maybe add some additional 'built-ins'.
Here are is a list of all the supported operators:
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 }} |
starts with | ?foo=^bar |
{ foo: { $regex: "^foo", $options: "i" }} |
ends with | ?foo=$bar |
{ foo: { $regex: "foo$", $options: "i" }} |
contains | ?foo=~bar |
{ foo: { $regex: "foo", $options: "i" }} |
bbox | ?bbox=~0,1,2,3 |
{ geojson: { $geoWithin: { $geometry: { … } } } } |
near | ?near=~0,1 |
{ geojson: { $near: { $geometry: { … } } } } |
after | ?after=1388534400 |
{ endret: { $gte: "2014-01-01T00:00:00.000Z" } } |
I have added this list to README, feel free to open this issue if you feel more examples are necessary.
@brianjd just a heads up, I have now added a propper example application: https://github.com/Turistforeningen/node-mongo-querystring/blob/master/examples/app.js
Better examples are needed, preferably a complete scenario.