Skip to content

Commit a184536

Browse files
committed
DOCS-827 migrate query and nulls wiki
1 parent 79d75e4 commit a184536

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

source/faq/developers.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff 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

source/reference/operator/exists.txt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ $exists
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()>`

0 commit comments

Comments
 (0)