Skip to content

Commit ab569e2

Browse files
jeff-allen-mongokay-kim
authored andcommitted
Adding copyable compass filters and expanding screenshots
1 parent f531137 commit ab569e2

20 files changed

+129
-14
lines changed
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
29.1 KB
Loading

source/includes/driver-example-query-29.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,21 @@
2020

2121
.. include:: /includes/fact-mws.rst
2222

23+
- id: compass
24+
content: |
25+
.. code-block:: javascript
26+
27+
[
28+
{ item: "journal", instock: [ { warehouse: "A", qty: 5 }, { warehouse: "C", qty: 15 } ] },
29+
{ item: "notebook", instock: [ { warehouse: "C", qty: 5 } ] },
30+
{ item: "paper", instock: [ { warehouse: "A", qty: 60 }, { warehouse: "B", qty: 15 } ] },
31+
{ item: "planner", instock: [ { warehouse: "A", qty: 40 }, { warehouse: "B", qty: 5 } ] },
32+
{ item: "postcard", instock: [ { warehouse: "B", qty: 15 }, { warehouse: "C", qty: 35 } ] }
33+
]
34+
35+
For instructions on inserting documents in MongoDB Compass, see
36+
:doc:`Insert Documents </tutorial/insert-documents/>`.
37+
2338
- id: python
2439
content: |
2540
.. class:: copyable-code

source/includes/driver-example-query-30.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
99
db.inventory.find( { "instock": { warehouse: "A", qty: 5 } } )
1010
11+
- id: compass
12+
content: |
13+
Copy the following filter into the Compass query bar and click
14+
:guilabel:`Find`:
15+
16+
.. class:: copyable-code
17+
.. code-block:: javascript
18+
19+
{ "instock": { warehouse: "A", qty: 5 } }
20+
21+
.. figure:: /images/compass-find-nested-in-array.png
22+
1123
- id: python
1224
content: |
1325
.. class:: copyable-code

source/includes/driver-example-query-31.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
99
db.inventory.find( { "instock": { qty: 5, warehouse: "A" } } )
1010
11+
- id: compass
12+
content: |
13+
.. figure:: /images/compass-find-nested-array-no-match.png
14+
1115
- id: python
1216
content: |
1317
.. class:: copyable-code

source/includes/driver-example-query-32.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
99
db.inventory.find( { 'instock.0.qty': { $lte: 20 } } )
1010
11+
- id: compass
12+
content: |
13+
Copy the following filter into the Compass query bar and click
14+
:guilabel:`Find`:
15+
16+
.. class:: copyable-code
17+
.. code-block:: javascript
18+
19+
{ 'instock.0.qty': { $lte: 20 } }
20+
21+
.. figure:: /images/compass-find-array-index-embedded-doc.png
22+
1123
- id: python
1224
content: |
1325
.. class:: copyable-code

source/includes/driver-example-query-33.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
99
db.inventory.find( { 'instock.qty': { $lte: 20 } } )
1010
11+
- id: compass
12+
content: |
13+
Copy the following filter into the Compass query bar and click
14+
:guilabel:`Find`:
15+
16+
.. class:: copyable-code
17+
.. code-block:: javascript
18+
19+
{ 'instock.qty': { $lte: 20 } }
20+
21+
.. figure:: /images/compass-find-array-embedded-field-condition.png
22+
1123
- id: python
1224
content: |
1325
.. class:: copyable-code

source/includes/driver-example-query-34.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
99
db.inventory.find( { "instock": { $elemMatch: { qty: 5, warehouse: "A" } } } )
1010
11+
- id: compass
12+
content: |
13+
Copy the following filter into the Compass query bar and click
14+
:guilabel:`Find`:
15+
16+
.. class:: copyable-code
17+
.. code-block:: javascript
18+
19+
{ "instock": { $elemMatch: { qty: 5, warehouse: "A" } } }
20+
21+
.. figure:: /images/compass-array-multiple-cond-single-doc.png
22+
1123
- id: python
1224
content: |
1325
.. class:: copyable-code

source/includes/driver-example-query-35.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
99
db.inventory.find( { "instock": { $elemMatch: { qty: { $gt: 10, $lte: 20 } } } } )
1010
11+
- id: compass
12+
content: |
13+
Copy the following filter into the Compass query bar and click
14+
:guilabel:`Find`:
15+
16+
.. class:: copyable-code
17+
.. code-block:: javascript
18+
19+
{ "instock": { $elemMatch: { qty: { $gt: 10, $lte: 20 } } } }
20+
21+
.. figure:: /images/compass-array-multiple-cond-single-doc-2.png
22+
1123
- id: python
1224
content: |
1325
.. class:: copyable-code

source/includes/driver-example-query-36.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
99
db.inventory.find( { "instock.qty": { $gt: 10, $lte: 20 } } )
1010
11+
- id: compass
12+
content: |
13+
Copy the following filter into the Compass query bar and click
14+
:guilabel:`Find`:
15+
16+
.. class:: copyable-code
17+
.. code-block:: javascript
18+
19+
{ "instock.qty": { $gt: 10, $lte: 20 } }
20+
21+
.. figure:: /images/compass-array-match-combination-of-elements.png
22+
1123
- id: python
1224
content: |
1325
.. class:: copyable-code

source/includes/driver-example-query-37.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
99
db.inventory.find( { "instock.qty": 5, "instock.warehouse": "A" } )
1010
11+
- id: compass
12+
content: |
13+
Copy the following filter into the Compass query bar and click
14+
:guilabel:`Find`:
15+
16+
.. class:: copyable-code
17+
.. code-block:: javascript
18+
19+
{ "instock.qty": 5, "instock.warehouse": "A" }
20+
21+
.. figure:: /images/compass-array-match-combination-of-elements-2.png
22+
1123
- id: python
1224
content: |
1325
.. class:: copyable-code

source/includes/driver-example-query-intro.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
``inventory`` collection. To populate the ``inventory``
1010
collection, run the following:
1111

12+
- id: compass
13+
content: |
14+
This page provides examples of |query_operations| in
15+
:ref:`MongoDB Compass <compass-index>`. The examples on this
16+
page use the ``inventory`` collection. Populate the
17+
``inventory`` collection with the following documents:
18+
1219
- id: python
1320
content: |
1421
This page provides examples of |query_operations| using the

source/tutorial/query-array-of-documents.txt

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Query an Array of Embedded Documents
2222
Query for a Document Nested in an Array
2323
---------------------------------------
2424

25-
The following examples selects all documents where an element in the
25+
The following example selects all documents where an element in the
2626
``instock`` array matches the specified document:
2727

2828
.. include:: /includes/driver-example-query-30.rst
@@ -37,19 +37,6 @@ example, the following query does not match any documents in the
3737
Specify a Query Condition on a Field in an Array of Documents
3838
-------------------------------------------------------------
3939

40-
Use the Array Index to Query for a Field in the Embedded Document
41-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42-
43-
Using the :term:`dot notation`, you can specify query conditions for
44-
field in a document at a particular index or position of the array. The
45-
array uses zero-based indexing.
46-
47-
The following example selects all documents where the ``instock`` array
48-
has as its first element a document that contains the field ``qty``
49-
whose value is less than or equal to ``20``:
50-
51-
.. include:: /includes/driver-example-query-32.rst
52-
5340
Specify a Query Condition on a Field Embedded in an Array of Documents
5441
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5542

@@ -63,6 +50,24 @@ whose value is less than or equal to ``20``:
6350

6451
.. include:: /includes/driver-example-query-33.rst
6552

53+
Use the Array Index to Query for a Field in the Embedded Document
54+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55+
56+
Using :term:`dot notation`, you can specify query conditions for
57+
field in a document at a particular index or position of the array. The
58+
array uses zero-based indexing.
59+
60+
.. note::
61+
62+
When querying using dot notation, the field and index must be
63+
inside quotation marks.
64+
65+
The following example selects all documents where the ``instock`` array
66+
has as its first element a document that contains the field ``qty``
67+
whose value is less than or equal to ``20``:
68+
69+
.. include:: /includes/driver-example-query-32.rst
70+
6671
Specify Multiple Conditions for Array of Documents
6772
--------------------------------------------------
6873

0 commit comments

Comments
 (0)