File tree Expand file tree Collapse file tree 2 files changed +12
-11
lines changed
Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -455,6 +455,9 @@ Different query operators treat ``null`` values differently:
455455
456456 .. code-block:: javascript
457457
458+ { "_id" : 1, "cancelDate" : null }
459+ { "_id" : 2 }
460+
458461- The ``{ cancelDate : { $type: 10 } }`` query matches documents that
459462 contains the ``cancelDate`` field whose value is ``null`` *only*;
460463 i.e. the value of the ``cancelDate`` field is of BSON Type ``Null``
@@ -471,13 +474,14 @@ Different query operators treat ``null`` values differently:
471474 { "_id" : 1, "cancelDate" : null }
472475
473476- The ``{ cancelDate : { $exists: false } }`` query matches documents
474- that that do not contain the ``cancelDate`` field:
477+ that do not contain the ``cancelDate`` field:
475478
476479 .. code-block:: javascript
477480
478481 db.test.find( { cancelDate : { $exists: false } } )
479482
480- The query returns only the document that contains the ``null`` value:
483+ The query returns only the document that does *not* contain the
484+ ``cancelDate`` field:
481485
482486 .. code-block:: javascript
483487
Original file line number Diff line number Diff line change 66
77.. operator:: $exists
88
9- *Syntax*: ``{ field: { $exists: boolean } }``
9+ *Syntax*: ``{ field: { $exists: < boolean> } }``
1010
11- :operator:`$exists` selects the documents that contain the field.
11+ :operator:`$exists` selects the documents that contain the field if
12+ ``<boolean>`` is ``true``. If ``<boolean>`` is ``false``, the query
13+ only returns the documents that do not contain the field. Documents
14+ that contain the field but has the value ``null`` are *not* returned.
15+
1216 MongoDB `$exists` does **not** correspond to SQL operator
1317 ``exists``. For SQL ``exists``, refer to the :operator:`$in`
1418 operator.
@@ -23,13 +27,6 @@ $exists
2327 where the ``qty`` field exists *and* its value does not equal either
2428 ``5`` nor ``15``.
2529
26- .. note::
27-
28- If set to ``false``, the query only returns those documents that
29- do not contain the field and *not* documents that contain the
30- field but has the value ``null``.
31-
32-
3330 .. seealso::
3431
3532 - :method:`find() <db.collection.find()>`
You can’t perform that action at this time.
0 commit comments