Skip to content
This repository was archived by the owner on May 1, 2025. It is now read-only.

Commit 58cb81b

Browse files
author
Hans Kristian Flaatten
committed
docs(readme): document all supported URL query opertors
1 parent 6f84fd0 commit 58cb81b

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

README.md

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,35 @@ useful when building an API and accepting various user specificed queries.
1717
* `$lt`
1818
* `$regex`
1919
* `$exists`
20+
21+
| operation | query string | query object |
22+
|-----------|---------------|--------------|
23+
| equal | `?foo=bar` | `{ foo: "bar" }` |
24+
| unequal | `?foo=!bar` | `{ foo: { $ne: "bar" }}` |
25+
| exists | `?foo=` | `{ foo: { $exists: true }}` |
26+
| not exists | `?foo=!` | `{ foo: { $exists: false }}` |
27+
| greater than | `?foo=>10` | `{ foo: { $gt: 10 }}` |
28+
| less than | `?foo=<10` | `{ foo: { $lt: 10 }}` |
29+
| starts with | `?foo=^bar` | `{ foo: { $regex: "^foo", $options: "i" }}` |
30+
| ends with | `?foo=$bar` | `{ foo: { $regex: "foo$", $options: "i" }}` |
31+
| contains | `?foo=~bar` | `{ foo: { $regex: "foo", $options: "i" }}` |
32+
2033
* Geospatial operators
21-
* `$geoWithin`
22-
* `$near`
34+
* `$geoWithin` (polygon)
35+
* `$near` (point)
36+
37+
| operation | query string | query object |
38+
|-----------|---------------|--------------|
39+
| bbox | `?bbox=~0,1,2,3` | `{ geojson: { $geoWithin: { $geometry: { … } } } }` |
40+
| near | `?near=~0,1` | `{ geojson: { $near: { $geometry: { … } } } }` |
41+
2342
* Custom query functions
43+
* `after` (date)
44+
45+
| operation | query string | query object |
46+
|-----------|---------------|--------------|
47+
| after | `?after=2014-01-01` | `{ endret: { $gte: "2014-01-01T00:00:00.000Z" } }` |
48+
| after | `?after=1388534400` | `{ endret: { $gte: "2014-01-01T00:00:00.000Z" } }` |
2449

2550
## Install
2651

@@ -44,8 +69,8 @@ var MongoQS = require('mongo-querystring');
4469

4570
#### Bult in custom queries
4671

47-
* `bbox` - bounding box query
48-
* `near` - proximity query
72+
* `bbox` - bounding box geostatial query
73+
* `near` - proximity geostatial query
4974
* `after` - modified since query
5075

5176
#### Define custom queries
@@ -81,4 +106,3 @@ mongo.collection('mycol').find(query, field).toArray(function(err, documents) {
81106
```
82107

83108
## [MIT Licensed](https://raw.githubusercontent.com/Turistforeningen/node-mongo-querystring/master/LICENSE)
84-

0 commit comments

Comments
 (0)