@@ -19,14 +19,14 @@ Query Documents
19
19
:backlinks: none
20
20
:depth: 1
21
21
22
- ----------
22
+ You can query documents in MongoDB by using the following
23
+ methods:
23
24
24
- .. |arrow| unicode :: U+27A4
25
+ .. |atlas-ref| replace :: :ref:`query-documents-atlas-ui`
25
26
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
28
28
29
- ----------
29
+ .. include:: /includes/language-selector-instructions.rst
30
30
31
31
.. tabs-selector:: drivers
32
32
@@ -251,6 +251,40 @@ which corresponds to the following SQL statement:
251
251
MongoDB supports regular expressions :query:`$regex` queries to
252
252
perform string pattern matches.
253
253
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
+
254
288
Additional Query Tutorials
255
289
--------------------------
256
290
@@ -383,15 +417,15 @@ To learn how to iterate through documents in a cursor, refer to your
383
417
:driver:`driver's documentation </>`. If you are using ``mongosh``, see
384
418
:ref:`read-operations-cursors`.
385
419
420
+ Additional Methods and Options
421
+ ------------------------------
422
+
386
423
.. tabs-drivers::
387
424
388
425
tabs:
389
426
- id: shell
390
427
content: |
391
428
392
- Additional Methods
393
- ------------------
394
-
395
429
The following methods can also read documents from a collection:
396
430
397
431
- :method:`db.collection.findOne`
@@ -409,9 +443,6 @@ To learn how to iterate through documents in a cursor, refer to your
409
443
- id: compass
410
444
content: |
411
445
412
- Additional Options
413
- ------------------
414
-
415
446
In addition to ``filter``, MongoDB Compass also allows the
416
447
following options to be passed to the query bar:
417
448
@@ -437,9 +468,6 @@ To learn how to iterate through documents in a cursor, refer to your
437
468
- id: python
438
469
content: |
439
470
440
- Additional Methods
441
- ------------------
442
-
443
471
The following methods can also read documents from a collection:
444
472
445
473
- :py:meth:`pymongo.collection.Collection.find_one`
@@ -459,9 +487,6 @@ To learn how to iterate through documents in a cursor, refer to your
459
487
- id: java-sync
460
488
content: |
461
489
462
- Additional Methods
463
- ------------------
464
-
465
490
The following methods can also read documents from a collection:
466
491
467
492
- 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
472
497
- id: java-async
473
498
content: |
474
499
475
- Additional Methods
476
- ------------------
477
-
478
500
The following methods can also read documents from a collection:
479
501
480
502
- In :doc:`aggregation pipeline </core/aggregation-pipeline>`,
@@ -486,9 +508,6 @@ To learn how to iterate through documents in a cursor, refer to your
486
508
- id: nodejs
487
509
content: |
488
510
489
- Additional Methods
490
- ------------------
491
-
492
511
The following methods can also read documents from a collection:
493
512
494
513
- :node-api:`Collection.findOne() <Collection.html#findOne>`
@@ -510,9 +529,6 @@ To learn how to iterate through documents in a cursor, refer to your
510
529
- id: php
511
530
content: |
512
531
513
- Additional Methods
514
- ------------------
515
-
516
532
The following methods can also read documents from a collection:
517
533
518
534
- :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
534
550
- id: perl
535
551
content: |
536
552
537
- Additional Methods
538
- ------------------
539
-
540
553
The following methods can also read documents from a collection:
541
554
542
555
- :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
558
571
- id: ruby
559
572
content: |
560
573
561
- Additional Methods
562
- ------------------
563
-
564
574
The following methods can also read documents from a collection:
565
575
566
576
- 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
571
581
- id: scala
572
582
content: |
573
583
574
- Additional Methods
575
- ------------------
576
-
577
584
The following methods can also read documents from a collection:
578
585
579
586
- 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
583
590
- id: csharp
584
591
content: |
585
592
586
- Additional Methods
587
- ------------------
588
-
589
593
The following methods can also read documents from a collection:
590
594
591
595
- :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
607
611
- id: go
608
612
content: |
609
613
610
- Additional Methods
611
- ------------------
612
-
613
614
The following methods can also read documents from a collection:
614
615
615
616
- :go-api:`Collection.FindOne <mongo#Collection.FindOne>`
0 commit comments