@@ -21,14 +21,14 @@ Query for Null or Missing Fields
21
21
:backlinks: none
22
22
:depth: 1
23
23
24
- ----------
24
+ You can query for ``null`` or missing fields in MongoDB
25
+ using the following methods:
25
26
26
- .. |arrow| unicode :: U+27A4
27
+ .. |atlas-ref| replace :: :ref:`query-null-documents-atlas-ui`
27
28
28
- |arrow| Use the **Select your language** drop-down menu in the
29
- upper-right to set the language of the following examples.
29
+ .. include:: /includes/fact-methods.rst
30
30
31
- ----------
31
+ .. include:: /includes/language-selector-instructions.rst
32
32
33
33
.. tabs-selector:: drivers
34
34
@@ -364,3 +364,68 @@ The query only returns the document that does *not* contain the
364
364
.. [#type0]
365
365
366
366
.. include:: /includes/extracts/4.2-changes-type-0.rst
367
+
368
+ .. _query-null-documents-atlas-ui:
369
+
370
+ Query for Null or Missing Fields with {+atlas+}
371
+ ----------------------------------------------------
372
+
373
+ The example in this section uses the :atlas:`sample training dataset
374
+ </sample-data/sample-training/>`. To learn how to load the sample dataset
375
+ into your {+atlas+} deployment, see :atlas:`Load Sample Data
376
+ </sample-data/#std-label-load-sample-data>`.
377
+
378
+ To query for a ``null`` or missing field in {+atlas+}, follow these steps:
379
+
380
+ .. procedure::
381
+ :style: normal
382
+
383
+ .. step:: Navigate to the collection.
384
+
385
+ a. In the :atlas:`Atlas UI </atlas-ui/>`, click :guilabel:`Database` in the sidebar.
386
+ #. For the database deployment that contains the sample data, click :guilabel:`Browse Collections`.
387
+ #. In the left navigation pane, select the ``sample_training`` database.
388
+ #. Select the ``companies`` collection.
389
+
390
+ .. step:: Insert a blank document.
391
+
392
+ Click the :guilabel:`Insert Document` button to display the
393
+ dialog box, and then click :guilabel:`Insert`
394
+ to insert a document with only the ``_id`` field.
395
+
396
+ .. step:: Specify a query filter document.
397
+
398
+ To find a document that contains a ``null`` or missing value,
399
+ specify a :ref:`query filter document <document-query-filter>`
400
+ in the :guilabel:`Filter` field. A query filter document uses
401
+ :ref:`query operators <csfle-supported-query-operators>`
402
+ to specify search conditions.
403
+
404
+ Different query operators in MongoDB treat ``null`` values differently.
405
+ To apply a query filter, copying each of the following documents into the
406
+ :guilabel:`Filter` search bar and click :guilabel:`Apply`.
407
+
408
+ Use the following query filter to match documents that either contain a
409
+ ``description`` field with a ``null`` value or do not contain the
410
+ ``description`` field:
411
+
412
+ .. code-block:: javascript
413
+
414
+ { description : null }
415
+
416
+ Use the following query filter to match only documents that contain
417
+ a ``description`` field with a ``null`` value. This filter specifies
418
+ that the value of the field must be :ref:`BSON Type <bson-types>` ``Null``
419
+ (BSON Type 10):
420
+
421
+ .. code-block:: javascript
422
+
423
+ { description : { $type: 10 } }
424
+
425
+ Use the following query filter to match only documents that
426
+ do not contain the ``description`` field. Only the document
427
+ that you inserted earlier should appear:
428
+
429
+ .. code-block:: javascript
430
+
431
+ { description : { $exists: false } }
0 commit comments