Skip to content

DOCSP-1389 - Integrating Compass into projection tutorial #3133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added source/images/compass-project-all-fields.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/images/compass-project-embedded-fields.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/images/compass-project-exclude-fields.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/images/compass-project-suppress-id.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions source/includes/driver-example-query-42.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@

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

- id: compass
content: |
.. code-block:: javascript

[
{ item: "journal", status: "A", size: { h: 14, w: 21, uom: "cm" }, instock: [ { warehouse: "A", qty: 5 } ] },
{ item: "notebook", status: "A", size: { h: 8.5, w: 11, uom: "in" }, instock: [ { warehouse: "C", qty: 5 } ] },
{ item: "paper", status: "D", size: { h: 8.5, w: 11, uom: "in" }, instock: [ { warehouse: "A", qty: 60 } ] },
{ item: "planner", status: "D", size: { h: 22.85, w: 30, uom: "cm" }, instock: [ { warehouse: "A", qty: 40 } ] },
{ item: "postcard", status: "A", size: { h: 10, w: 15.25, uom: "cm" }, instock: [ { warehouse: "B", qty: 15 }, { warehouse: "C", qty: 35 } ] }
]

For instructions on inserting documents in MongoDB Compass,
see :doc:`Insert Documents </tutorial/insert-documents>`.


- id: python
content: |
.. class:: copyable-code
Expand Down
13 changes: 13 additions & 0 deletions source/includes/driver-example-query-43.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@

db.inventory.find( { status: "A" } )

- id: compass
content: |
Copy the following expression into the :guilabel:`Filter` bar
and click :guilabel:`Find`:

.. class:: copyable-code
.. code-block:: javascript

{ status: "A" }


.. figure:: /images/compass-project-all-fields.png

- id: python
content: |
.. class:: copyable-code
Expand Down
21 changes: 21 additions & 0 deletions source/includes/driver-example-query-44.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@

db.inventory.find( { status: "A" }, { item: 1, status: 1 } )

- id: compass
content: |
Copy the following expression into the :guilabel:`Filter` bar:

.. class:: copyable-code
.. code-block:: javascript

{ status: "A" }

Copy the following expression into the :guilabel:`Project`
bar:

.. class:: copyable-code
.. code-block:: javascript

{ item: 1, status: 1 }

Click :guilabel:`Find`.

.. figure:: /images/compass-project-specified-plus-id.png

- id: python
content: |
.. class:: copyable-code
Expand Down
21 changes: 21 additions & 0 deletions source/includes/driver-example-query-45.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@

db.inventory.find( { status: "A" }, { item: 1, status: 1, _id: 0 } )

- id: compass
content: |
Copy the following expression into the :guilabel:`Filter` bar:

.. class:: copyable-code
.. code-block:: javascript

{ status: "A" }

Copy the following expression into the :guilabel:`Project`
bar:

.. class:: copyable-code
.. code-block:: javascript

{ item: 1, status: 1, _id: 0 }

Click :guilabel:`Find`.

.. figure:: /images/compass-project-suppress-id.png

- id: python
content: |
.. class:: copyable-code
Expand Down
21 changes: 21 additions & 0 deletions source/includes/driver-example-query-46.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@

db.inventory.find( { status: "A" }, { status: 0, instock: 0 } )

- id: compass
content: |
Copy the following expression into the :guilabel:`Filter` bar:

.. class:: copyable-code
.. code-block:: javascript

{ status: "A" }

Copy the following expression into the :guilabel:`Project`
bar:

.. class:: copyable-code
.. code-block:: javascript

{ status: 0, instock: 0 }

Click :guilabel:`Find`.

.. figure:: /images/compass-project-exclude-fields.png

- id: python
content: |
.. class:: copyable-code
Expand Down
21 changes: 21 additions & 0 deletions source/includes/driver-example-query-47.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@
{ item: 1, status: 1, "size.uom": 1 }
)

- id: compass
content: |
Copy the following expression into the :guilabel:`Filter` bar:

.. class:: copyable-code
.. code-block:: javascript

{ status: "A" }

Copy the following expression into the :guilabel:`Project`
bar:

.. class:: copyable-code
.. code-block:: javascript

{ item: 1, status: 1, "size.uom": 1 }

Click :guilabel:`Find`.

.. figure:: /images/compass-project-embedded-fields.png

- id: python
content: |
.. class:: copyable-code
Expand Down
21 changes: 21 additions & 0 deletions source/includes/driver-example-query-48.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@
{ "size.uom": 0 }
)

- id: compass
content: |
Copy the following expression into the :guilabel:`Filter` bar:

.. class:: copyable-code
.. code-block:: javascript

{ status: "A" }

Copy the following expression into the :guilabel:`Project`
bar:

.. class:: copyable-code
.. code-block:: javascript

{ "size.uom": 0 }

Click :guilabel:`Find`.

.. figure:: /images/compass-project-suppress-embedded-field.png

- id: python
content: |
.. class:: copyable-code
Expand Down
21 changes: 21 additions & 0 deletions source/includes/driver-example-query-49.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@

db.inventory.find( { status: "A" }, { item: 1, status: 1, "instock.qty": 1 } )

- id: compass
content: |
Copy the following expression into the :guilabel:`Filter` bar:

.. class:: copyable-code
.. code-block:: javascript

{ status: "A" }

Copy the following expression into the :guilabel:`Project`
bar:

.. class:: copyable-code
.. code-block:: javascript

{ item: 1, status: 1, "instock.qty": 1 }

Click :guilabel:`Find`.

.. figure:: /images/compass-project-embedded-array-docs.png

- id: python
content: |
.. class:: copyable-code
Expand Down
2 changes: 1 addition & 1 deletion source/includes/driver-example-query-50.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.. class:: copyable-code
.. code-block:: javascript
db.inventory.find( { status: "A" }, { name: 1, status: 1, instock: { $slice: -1 } } )
db.inventory.find( { status: "A" }, { item: 1, status: 1, instock: { $slice: -1 } } )
- id: python
content: |
Expand Down
7 changes: 7 additions & 0 deletions source/includes/driver-example-query-intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
``inventory`` collection. To populate the ``inventory``
collection, run the following:

- id: compass
content: |
This page provides examples of |query_operations| in
:ref:`MongoDB Compass <compass-index>`. The examples on this
page use the ``inventory`` collection. Populate the
``inventory`` collection with the following documents:

- id: python
content: |
This page provides examples of |query_operations| using the
Expand Down
3 changes: 3 additions & 0 deletions source/includes/fact-projection-ops.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
For fields that contain arrays, MongoDB provides the following
projection operators for manipulating arrays: :projection:`$elemMatch`,
:projection:`$slice`, and :projection:`$`.
2 changes: 2 additions & 0 deletions source/includes/fact-projection-slice-example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The following example uses the :projection:`$slice` projection operator
to return the last element in the ``instock`` array:
Loading