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