Skip to content

Commit dc6a371

Browse files
authored
(DOCSP-32012) Adds procedure to project fields from query results in Atlas (#4822)
* (DOCSP-32012) Adds procedure to project fields from query results in Atlas * Includes changes from copy review
1 parent 11f7bbd commit dc6a371

File tree

1 file changed

+67
-7
lines changed

1 file changed

+67
-7
lines changed

source/tutorial/project-fields-from-query-results.txt

Lines changed: 67 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@ Project Fields to Return from Query
2323
:backlinks: none
2424
:depth: 1
2525

26-
----------
26+
You can query embedded documents in MongoDB by using the following
27+
methods:
2728

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
3431

32+
.. include:: /includes/language-selector-instructions.rst
33+
3534
.. tabs-selector:: drivers
3635

3736
By default, queries in MongoDB return all fields in matching documents.
@@ -413,6 +412,67 @@ Project Specific Array Elements in the Returned Array
413412
``include("instock.0")`` projection will *not* project the array
414413
with the first element.
415414

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+
416476
Additional Considerations
417477
-------------------------
418478

0 commit comments

Comments
 (0)