Skip to content

Commit 0f90b78

Browse files
jeff-allen-mongokay-kim
authored andcommitted
DOCSP-1458 - Integrating Compass tab into Update Documents tutorial
1 parent 7201f66 commit 0f90b78

18 files changed

+491
-66
lines changed

conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ def has(self, *args):
6565
'.. |hardlink| replace:: {0}/{1}'.format(conf.project.url, conf.git.branches.current),
6666
'.. |branch| replace:: ``{0}``'.format(conf.git.branches.current),
6767
'.. |bi| replace:: MongoDB Connector for BI',
68-
'.. |version| replace:: {0}'.format(version)
68+
'.. |version| replace:: {0}'.format(version),
69+
'.. |compass| replace:: MongoDB Compass'
6970
])
7071

7172
pygments_style = 'sphinx'
211 KB
Loading
Loading
Loading
223 KB
Loading
212 KB
Loading
206 KB
Loading
282 KB
Loading
25 KB
Loading
64.9 KB
Loading

source/includes/driver-example-update-51.rst

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,34 @@
1717
{ item: "postcard", qty: 45, size: { h: 10, w: 15.25, uom: "cm" }, status: "A" },
1818
{ item: "sketchbook", qty: 80, size: { h: 14, w: 21, uom: "cm" }, status: "A" },
1919
{ item: "sketch pad", qty: 95, size: { h: 22.85, w: 30.5, uom: "cm" }, status: "A" }
20-
]);
20+
] );
2121
2222
.. only:: website
2323

2424
You can run the operation in the web shell below:
2525

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

28+
- id: compass
29+
content: |
30+
.. code-block:: javascript
31+
32+
[
33+
{ item: "canvas", qty: 100, size: { h: 28, w: 35.5, uom: "cm" }, status: "A" },
34+
{ item: "journal", qty: 25, size: { h: 14, w: 21, uom: "cm" }, status: "A" },
35+
{ item: "mat", qty: 85, size: { h: 27.9, w: 35.5, uom: "cm" }, status: "A" },
36+
{ item: "mousepad", qty: 25, size: { h: 19, w: 22.85, uom: "cm" }, status: "P" },
37+
{ item: "notebook", qty: 50, size: { h: 8.5, w: 11, uom: "in" }, status: "P" },
38+
{ item: "paper", qty: 100, size: { h: 8.5, w: 11, uom: "in" }, status: "D" },
39+
{ item: "planner", qty: 75, size: { h: 22.85, w: 30, uom: "cm" }, status: "D" },
40+
{ item: "postcard", qty: 45, size: { h: 10, w: 15.25, uom: "cm" }, status: "A" },
41+
{ item: "sketchbook", qty: 80, size: { h: 14, w: 21, uom: "cm" }, status: "A" },
42+
{ item: "sketch pad", qty: 95, size: { h: 22.85, w: 30.5, uom: "cm" }, status: "A" }
43+
]
44+
45+
For instructions on inserting documents using |compass|, see
46+
:doc:`Insert Documents </tutorial/insert-documents/>`.
47+
2848
- id: python
2949
content: |
3050
.. class:: copyable-code

source/includes/driver-example-update-52.rst

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,99 @@
1414
}
1515
)
1616
17+
.. include:: /includes/fact-update-operation-uses.rst
18+
19+
- id: compass
20+
content: |
21+
Modify the target document as follows:
22+
23+
- Change the ``status`` field from ``D`` to ``P``.
24+
25+
- Change the ``size.uom`` field from ``in`` to ``cm``.
26+
27+
- Add a new field called ``lastModified`` whose value will
28+
be today's date.
29+
30+
1. Click the :guilabel:`Table` button in the top navigation
31+
to access the :ref:`Table View <documents-table-view>`:
32+
33+
.. figure:: /images/compass-table-btn-click.png
34+
:alt: Access Table View
35+
36+
#. Use the Compass :ref:`query bar <query-bar-filter>` to
37+
locate the target document.
38+
39+
Copy the following filter document into the query bar and click
40+
:guilabel:`Find`:
41+
42+
.. class:: copyable-code
43+
.. code-block:: javascript
44+
45+
{ item: "paper" }
46+
47+
.. figure:: /images/compass-update-paper-filter.png
48+
:alt: Find Paper document
49+
50+
#. Hover over the ``status`` field and click the pencil icon
51+
which appears on the right side of the document to enter
52+
edit mode:
53+
54+
.. figure:: /images/compass-edit-paper-example.png
55+
:alt: Click edit button
56+
57+
#. Change the value of the field to ``"P"``.
58+
59+
#. Click the :guilabel:`Update` button below the field to
60+
save your changes.
61+
62+
#. Hover over the ``size`` field and click the
63+
outward-pointing arrows which appear on the right side of
64+
the field. This opens a new tab which displays the fields
65+
within the ``size`` object:
66+
67+
.. figure:: /images/compass-edit-paper-expand.png
68+
:alt: Expand size object
69+
70+
#. Using the same process outlined in steps 3-5 for editing the
71+
``status`` field, change the value of the ``size.uom`` field
72+
to ``"cm"``.
73+
74+
#. Click the left-most tab above the table labelled
75+
``inventory`` to return to the original table view, which
76+
displays the top-level document:
77+
78+
.. figure:: /images/compass-edit-inv-tab-click.png
79+
:alt: Click inventory tab
80+
81+
#. Hover over the ``status`` field and click the pencil icon
82+
which appears on the right side of the document to re-enter
83+
edit mode.
84+
85+
#. Click inside of the ``status`` field and click the
86+
:guilabel:`plus button` icon which appears in the edit menu.
87+
88+
Click the :guilabel:`Add Field After status` button which
89+
appears below the plus button:
90+
91+
.. figure:: /images/compass-edit-paper-add-field-after.png
92+
:alt: Add field after status
93+
94+
#. Add a new field called ``lastModified`` with a value of
95+
today's date. Set the field type to ``Date``:
96+
97+
.. figure:: /images/compass-edit-paper-add-last-modified.png
98+
:alt: Submit update
99+
100+
#. Click the :guilabel:`Update` button below the field to
101+
save your changes.
102+
103+
.. note::
104+
105+
Because |compass| does not support
106+
:update:`$currentDate` or any other
107+
:doc:`Field Update Operators </reference/operator/update-field>`,
108+
you must manually enter the date value in Compass.
109+
17110
- id: python
18111
content: |
19112
.. class:: copyable-code
@@ -23,6 +116,8 @@
23116
:start-after: Start Example 52
24117
:end-before: End Example 52
25118

119+
.. include:: /includes/fact-update-operation-uses.rst
120+
26121
- id: java-sync
27122
content: |
28123
.. class:: copyable-code
@@ -32,6 +127,8 @@
32127
:start-after: Start Example 52
33128
:end-before: End Example 52
34129

130+
.. include:: /includes/fact-update-operation-uses.rst
131+
35132
- id: java-async
36133
content: |
37134
.. class:: copyable-code
@@ -41,6 +138,8 @@
41138
:start-after: Start Example 52
42139
:end-before: End Example 52
43140

141+
.. include:: /includes/fact-update-operation-uses.rst
142+
44143
- id: nodejs
45144
content: |
46145
.. class:: copyable-code
@@ -50,6 +149,8 @@
50149
:start-after: Start Example 52
51150
:end-before: End Example 52
52151

152+
.. include:: /includes/fact-update-operation-uses.rst
153+
53154
- id: php
54155
content: |
55156
.. class:: copyable-code
@@ -59,6 +160,8 @@
59160
:start-after: Start Example 52
60161
:end-before: End Example 52
61162

163+
.. include:: /includes/fact-update-operation-uses.rst
164+
62165
- id: perl
63166
content: |
64167
.. class:: copyable-code
@@ -68,6 +171,8 @@
68171
:start-after: Start Example 52
69172
:end-before: End Example 52
70173

174+
.. include:: /includes/fact-update-operation-uses.rst
175+
71176
- id: ruby
72177
content: |
73178
.. class:: copyable-code
@@ -77,6 +182,8 @@
77182
:start-after: Start Example 52
78183
:end-before: End Example 52
79184

185+
.. include:: /includes/fact-update-operation-uses.rst
186+
80187
- id: scala
81188
content: |
82189
.. class:: copyable-code
@@ -86,6 +193,8 @@
86193
:start-after: Start Example 52
87194
:end-before: End Example 52
88195

196+
.. include:: /includes/fact-update-operation-uses.rst
197+
89198
- id: csharp
90199
content: |
91200
.. class:: copyable-code
@@ -94,3 +203,5 @@
94203
:dedent: 12
95204
:start-after: Start Example 52
96205
:end-before: End Example 52
206+
207+
.. include:: /includes/fact-update-operation-uses.rst

source/includes/driver-example-update-53.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
}
1515
)
1616
17+
.. include:: /includes/fact-update-many-operation-uses.rst
18+
1719
- id: python
1820
content: |
1921
.. class:: copyable-code
@@ -23,6 +25,8 @@
2325
:start-after: Start Example 53
2426
:end-before: End Example 53
2527

28+
.. include:: /includes/fact-update-many-operation-uses.rst
29+
2630
- id: java-sync
2731
content: |
2832
.. class:: copyable-code
@@ -32,6 +36,8 @@
3236
:start-after: Start Example 53
3337
:end-before: End Example 53
3438

39+
.. include:: /includes/fact-update-many-operation-uses.rst
40+
3541
- id: java-async
3642
content: |
3743
.. class:: copyable-code
@@ -41,6 +47,8 @@
4147
:start-after: Start Example 53
4248
:end-before: End Example 53
4349

50+
.. include:: /includes/fact-update-many-operation-uses.rst
51+
4452
- id: nodejs
4553
content: |
4654
.. class:: copyable-code
@@ -50,6 +58,8 @@
5058
:start-after: Start Example 53
5159
:end-before: End Example 53
5260

61+
.. include:: /includes/fact-update-many-operation-uses.rst
62+
5363
- id: php
5464
content: |
5565
.. class:: copyable-code
@@ -59,6 +69,8 @@
5969
:start-after: Start Example 53
6070
:end-before: End Example 53
6171

72+
.. include:: /includes/fact-update-many-operation-uses.rst
73+
6274
- id: perl
6375
content: |
6476
.. class:: copyable-code
@@ -68,6 +80,8 @@
6880
:start-after: Start Example 53
6981
:end-before: End Example 53
7082

83+
.. include:: /includes/fact-update-many-operation-uses.rst
84+
7185
- id: ruby
7286
content: |
7387
.. class:: copyable-code
@@ -77,6 +91,8 @@
7791
:start-after: Start Example 53
7892
:end-before: End Example 53
7993

94+
.. include:: /includes/fact-update-many-operation-uses.rst
95+
8096
- id: scala
8197
content: |
8298
.. class:: copyable-code
@@ -86,6 +102,8 @@
86102
:start-after: Start Example 53
87103
:end-before: End Example 53
88104

105+
.. include:: /includes/fact-update-many-operation-uses.rst
106+
89107
- id: csharp
90108
content: |
91109
.. class:: copyable-code
@@ -94,3 +112,5 @@
94112
:dedent: 12
95113
:start-after: Start Example 53
96114
:end-before: End Example 53
115+
116+
.. include:: /includes/fact-update-many-operation-uses.rst
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
The update operation:
2+
3+
- uses the :update:`$set` operator to update the value of the
4+
``size.uom`` field to ``"in"`` and the value of the ``status``
5+
field to ``"P"``,
6+
7+
- uses the :update:`$currentDate` operator to update the value
8+
of the ``lastModified`` field to the current date. If
9+
``lastModified`` field does not exist,
10+
:update:`$currentDate` will create the field. See
11+
:update:`$currentDate` for details.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
The update operation:
2+
3+
- uses the :update:`$set` operator to update the value of the
4+
``size.uom`` field to ``"cm"`` and the value of the ``status``
5+
field to ``"P"``,
6+
7+
- uses the :update:`$currentDate` operator to update the value
8+
of the ``lastModified`` field to the current date. If
9+
``lastModified`` field does not exist,
10+
:update:`$currentDate` will create the field. See
11+
:update:`$currentDate` for details.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
When replacing a document, the replacement document must consist of only
2+
field/value pairs; i.e. do not include :manual:`update operators
3+
</reference/operator/update>` expressions.
4+
5+
The replacement document can have different fields from the original
6+
document. In the replacement document, you can omit the ``_id`` field
7+
since the ``_id`` field is immutable; however, if you do include the
8+
``_id`` field, it must have the same value as the current value.
9+
10+
.. _write-op-replaceOne:
11+
12+
The following example replaces the *first* document from the
13+
``inventory`` collection where ``item: "paper"``:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Some update operators, such as :update:`$set`, will create the field if
2+
the field does not exist. See the individual
3+
:manual:`update operator </reference/operator/update>` reference for
4+
details.

0 commit comments

Comments
 (0)