diff --git a/API.md b/API.md index a0ce9eb..e87338a 100644 --- a/API.md +++ b/API.md @@ -70,7 +70,7 @@ documents, arrays, arrays of subdocuments and to match a specific element of an
  • $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 should be true or false
  • +
  • $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, because it doesn't give you more power than regex flags. Basic queries are more readable so only use the $regex operator when you need to use another operator with it
  • @@ -972,7 +972,7 @@ documents, arrays, arrays of subdocuments and to match a specific element of an
  • $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 should be true or false
  • +
  • $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, because it doesn't give you more power than regex flags. Basic queries are more readable so only use the $regex operator when you need to use another operator with it
  • diff --git a/README.md b/README.md index c629bff..7383a7d 100755 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/datastore.js b/lib/datastore.js index 50e04a6..915e842 100755 --- a/lib/datastore.js +++ b/lib/datastore.js @@ -89,7 +89,7 @@ const { isDate, pick, filterIndexNames } = require('./utils.js') * - `$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` should be true or false + * - `$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, because it doesn't give you more power than regex flags. Basic * queries are more readable so only use the `$regex` operator when you need to use another operator with it diff --git a/test/model.test.js b/test/model.test.js index 17f5f70..f845f1f 100755 --- a/test/model.test.js +++ b/test/model.test.js @@ -1169,7 +1169,7 @@ describe('Model', function () { }) // General behaviour is tested in the block about $lt. Here we just test operators work - describe('Other comparison operators: $lte, $gt, $gte, $ne, $in, $stat', function () { + describe('Other comparison operators: $lte, $gt, $gte, $ne, $in, $exists', function () { it('$lte', function () { model.match({ a: 5 }, { a: { $lte: 6 } }).should.equal(true) model.match({ a: 5 }, { a: { $lte: 5 } }).should.equal(true)