@@ -23,15 +23,14 @@ Project Fields to Return from Query
23
23
:backlinks: none
24
24
:depth: 1
25
25
26
- ----------
26
+ You can query embedded documents in MongoDB by using the following
27
+ methods:
27
28
28
- .. |arrow| unicode:: U+27A4
29
-
30
- |arrow| Use the **Select your language** drop-down menu in the
31
- upper-right to set the language of the following examples.
32
-
33
- ----------
29
+ .. |atlas-ref| replace:: :ref:`project-fields-atlas-ui`
30
+ .. include:: /includes/fact-methods.rst
34
31
32
+ .. include:: /includes/language-selector-instructions.rst
33
+
35
34
.. tabs-selector:: drivers
36
35
37
36
By default, queries in MongoDB return all fields in matching documents.
@@ -413,6 +412,67 @@ Project Specific Array Elements in the Returned Array
413
412
``include("instock.0")`` projection will *not* project the array
414
413
with the first element.
415
414
415
+ .. _project-fields-atlas-ui:
416
+
417
+ Project Fields to Return from a Query with {+atlas+}
418
+ -------------------------------------------------------------------
419
+
420
+ The example in this section uses the :atlas:`sample movies dataset
421
+ </sample-data/sample-mflix/>`. To learn how to load the sample dataset
422
+ into your {+atlas+} deployment, see :atlas:`Load Sample Data
423
+ </sample-data/#std-label-load-sample-data>`.
424
+
425
+ To project fields to return from a query in {+atlas+}, follow these
426
+ steps:
427
+
428
+ .. procedure::
429
+ :style: normal
430
+
431
+ .. step:: Navigate to the collection
432
+
433
+ .. include:: /includes/steps-nav-atlas-sample-movies.rst
434
+
435
+ .. step:: Specify the Filter field
436
+
437
+ a. Click :guilabel:`More Options` on the right side of the
438
+ :guilabel:`Filter` field.
439
+ #. Specify the query filter.
440
+
441
+ .. include:: /includes/steps-specify-query-filter.rst
442
+
443
+ .. code-block:: javascript
444
+
445
+ { year: 1924 }
446
+
447
+ .. step:: Specify the fields to project
448
+
449
+ Specify the field(s) to return in the query results.
450
+
451
+ Copy the following project document into the :guilabel:`Project`
452
+ bar:
453
+
454
+ .. code-block:: javascript
455
+
456
+ { title: 1, plot: 1 }
457
+
458
+ .. step:: Click Apply
459
+
460
+ This query filter returns the following fields for all documents
461
+ in the ``sample_mflix.movies`` collection where the ``year``
462
+ field matches ``1924``:
463
+
464
+ - ``_id``
465
+ - ``title``
466
+ - ``plot``
467
+
468
+ {+atlas+} returns the ``_id`` field by default. To omit the
469
+ ``_id`` field, copy the following project document
470
+ into the :guilabel:`Project` bar and click :guilabel:`Apply`:
471
+
472
+ .. code-block:: javascript
473
+
474
+ { title: 1, plot: 1, _id: 0 }
475
+
416
476
Additional Considerations
417
477
-------------------------
418
478
0 commit comments