|
|
|
@ -48,7 +48,7 @@ repository. It is generated by running `npm run generateDocs:markdown`. |
|
|
|
|
* [Inserting documents](#inserting-documents) |
|
|
|
|
* [Finding documents](#finding-documents) |
|
|
|
|
* [Basic Querying](#basic-querying) |
|
|
|
|
* [Operators ($lt, $lte, $gt, $gte, $in, $nin, $ne, $stat, $regex)](#operators-lt-lte-gt-gte-in-nin-ne-stat-regex) |
|
|
|
|
* [Operators ($lt, $lte, $gt, $gte, $in, $nin, $ne, $exists, $regex)](#operators-lt-lte-gt-gte-in-nin-ne-stat-regex) |
|
|
|
|
* [Array fields](#array-fields) |
|
|
|
|
* [Logical operators $or, $and, $not, $where](#logical-operators-or-and-not-where) |
|
|
|
|
* [Sorting and paginating](#sorting-and-paginating) |
|
|
|
@ -262,7 +262,7 @@ const doc = await db.findOneAsync({ _id: 'id1' }) |
|
|
|
|
// If no document is found, doc is null |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
#### Operators ($lt, $lte, $gt, $gte, $in, $nin, $ne, $stat, $regex) |
|
|
|
|
#### Operators ($lt, $lte, $gt, $gte, $in, $nin, $ne, $exists, $regex) |
|
|
|
|
|
|
|
|
|
The syntax is `{ field: { $op: value } }` where `$op` is any comparison |
|
|
|
|
operator: |
|
|
|
@ -271,7 +271,7 @@ operator: |
|
|
|
|
* `$gt`, `$gte`: greater than, greater than or equal |
|
|
|
|
* `$in`: member of. `value` must be an array of values |
|
|
|
|
* `$ne`, `$nin`: not equal, not a member of |
|
|
|
|
* `$stat`: checks whether the document posses the property `field`. `value` |
|
|
|
|
* `$exists`: checks whether the document posses the property `field`. `value` |
|
|
|
|
should be true or false |
|
|
|
|
* `$regex`: checks whether a string is matched by the regular expression. |
|
|
|
|
Contrary to MongoDB, the use of `$options` with `$regex` is not supported, |
|
|
|
@ -292,8 +292,8 @@ const docs = await db.findAsync({ planet: { $gt: 'Mercury' } }) |
|
|
|
|
const docs = await db.findAsync({ planet: { $in: ['Earth', 'Jupiter'] } }) |
|
|
|
|
// docs contains Earth and Jupiter |
|
|
|
|
|
|
|
|
|
// Using $stat |
|
|
|
|
const docs = await db.findAsync({ satellites: { $stat: true } }) |
|
|
|
|
// Using $exists |
|
|
|
|
const docs = await db.findAsync({ satellites: { $exists: true } }) |
|
|
|
|
// docs contains only Mars |
|
|
|
|
|
|
|
|
|
// Using $regex with another operator |
|
|
|
|