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