Skip to content

Commit faf28f4

Browse files
authored
(DOCSP-32020) Adds procedure to query documents with Atlas (#4823) (#4964)
1 parent 810aeff commit faf28f4

File tree

1 file changed

+42
-41
lines changed

1 file changed

+42
-41
lines changed

source/tutorial/query-documents.txt

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ Query Documents
1919
:backlinks: none
2020
:depth: 1
2121

22-
----------
22+
You can query documents in MongoDB by using the following
23+
methods:
2324

24-
.. |arrow| unicode:: U+27A4
25+
.. |atlas-ref| replace:: :ref:`query-documents-atlas-ui`
2526

26-
|arrow| Use the **Select your language** drop-down menu in the
27-
upper-right to set the language of the following examples.
27+
.. include:: /includes/fact-methods.rst
2828

29-
----------
29+
.. include:: /includes/language-selector-instructions.rst
3030

3131
.. tabs-selector:: drivers
3232

@@ -251,6 +251,40 @@ which corresponds to the following SQL statement:
251251
MongoDB supports regular expressions :query:`$regex` queries to
252252
perform string pattern matches.
253253

254+
.. _query-documents-atlas-ui:
255+
256+
Query Documents with {+atlas+}
257+
------------------------------------------
258+
259+
The example in this section uses the :atlas:`sample movies dataset
260+
</sample-data/sample-mflix/>`. To learn how to load the sample dataset
261+
into your {+atlas+} deployment, see :atlas:`Load Sample Data
262+
</sample-data/#std-label-load-sample-data>`.
263+
264+
To project fields to return from a query in {+atlas+}, follow these
265+
steps:
266+
267+
.. procedure::
268+
:style: normal
269+
270+
.. step:: Navigate to the collection
271+
272+
.. include:: /includes/steps-nav-atlas-sample-movies.rst
273+
274+
.. step:: Specify the :guilabel:`Filter` field
275+
276+
.. include:: /includes/steps-specify-query-filter.rst
277+
278+
.. code-block:: javascript
279+
280+
{ year: 1924 }
281+
282+
.. step:: Click :guilabel:`Apply`
283+
284+
This query filter returns all documents
285+
in the ``sample_mflix.movies`` collection where the ``year``
286+
field matches ``1924``.
287+
254288
Additional Query Tutorials
255289
--------------------------
256290

@@ -383,15 +417,15 @@ To learn how to iterate through documents in a cursor, refer to your
383417
:driver:`driver's documentation </>`. If you are using ``mongosh``, see
384418
:ref:`read-operations-cursors`.
385419

420+
Additional Methods and Options
421+
------------------------------
422+
386423
.. tabs-drivers::
387424

388425
tabs:
389426
- id: shell
390427
content: |
391428

392-
Additional Methods
393-
------------------
394-
395429
The following methods can also read documents from a collection:
396430

397431
- :method:`db.collection.findOne`
@@ -409,9 +443,6 @@ To learn how to iterate through documents in a cursor, refer to your
409443
- id: compass
410444
content: |
411445

412-
Additional Options
413-
------------------
414-
415446
In addition to ``filter``, MongoDB Compass also allows the
416447
following options to be passed to the query bar:
417448

@@ -437,9 +468,6 @@ To learn how to iterate through documents in a cursor, refer to your
437468
- id: python
438469
content: |
439470

440-
Additional Methods
441-
------------------
442-
443471
The following methods can also read documents from a collection:
444472

445473
- :py:meth:`pymongo.collection.Collection.find_one`
@@ -459,9 +487,6 @@ To learn how to iterate through documents in a cursor, refer to your
459487
- id: java-sync
460488
content: |
461489

462-
Additional Methods
463-
------------------
464-
465490
The following methods can also read documents from a collection:
466491

467492
- In the :doc:`aggregation pipeline </core/aggregation-pipeline>`,
@@ -472,9 +497,6 @@ To learn how to iterate through documents in a cursor, refer to your
472497
- id: java-async
473498
content: |
474499

475-
Additional Methods
476-
------------------
477-
478500
The following methods can also read documents from a collection:
479501

480502
- In :doc:`aggregation pipeline </core/aggregation-pipeline>`,
@@ -486,9 +508,6 @@ To learn how to iterate through documents in a cursor, refer to your
486508
- id: nodejs
487509
content: |
488510

489-
Additional Methods
490-
------------------
491-
492511
The following methods can also read documents from a collection:
493512

494513
- :node-api:`Collection.findOne() <Collection.html#findOne>`
@@ -510,9 +529,6 @@ To learn how to iterate through documents in a cursor, refer to your
510529
- id: php
511530
content: |
512531

513-
Additional Methods
514-
------------------
515-
516532
The following methods can also read documents from a collection:
517533

518534
- :phpmethod:`MongoDB\\Collection::findOne() <phpmethod.MongoDB\\Collection::findOne>`
@@ -534,9 +550,6 @@ To learn how to iterate through documents in a cursor, refer to your
534550
- id: perl
535551
content: |
536552

537-
Additional Methods
538-
------------------
539-
540553
The following methods can also read documents from a collection:
541554

542555
- :perl-api:`MongoDB::Collection::find_one()<Collection#find_one>`
@@ -558,9 +571,6 @@ To learn how to iterate through documents in a cursor, refer to your
558571
- id: ruby
559572
content: |
560573

561-
Additional Methods
562-
------------------
563-
564574
The following methods can also read documents from a collection:
565575

566576
- In :doc:`aggregation pipeline </core/aggregation-pipeline>`, the
@@ -571,9 +581,6 @@ To learn how to iterate through documents in a cursor, refer to your
571581
- id: scala
572582
content: |
573583

574-
Additional Methods
575-
------------------
576-
577584
The following methods can also read documents from a collection:
578585

579586
- In :doc:`aggregation pipeline </core/aggregation-pipeline>`, the
@@ -583,9 +590,6 @@ To learn how to iterate through documents in a cursor, refer to your
583590
- id: csharp
584591
content: |
585592

586-
Additional Methods
587-
------------------
588-
589593
The following methods can also read documents from a collection:
590594

591595
- :csharp-api:`MongoCollection.FindOne() <M_MongoDB_Driver_MongoCollection_1_FindOne_1>`
@@ -607,9 +611,6 @@ To learn how to iterate through documents in a cursor, refer to your
607611
- id: go
608612
content: |
609613

610-
Additional Methods
611-
------------------
612-
613614
The following methods can also read documents from a collection:
614615

615616
- :go-api:`Collection.FindOne <mongo#Collection.FindOne>`

0 commit comments

Comments
 (0)