Skip to content

Commit c030edc

Browse files
authored
(DOCSP-12499) documents are now updated not replaced, when modified (#319)
* (DOCSP-12499) documents are now updated not replaced, when modified * Included tech review and implemented includes
1 parent 2a9e5a2 commit c030edc

File tree

4 files changed

+62
-28
lines changed

4 files changed

+62
-28
lines changed

source/documents/modify.txt

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ Modify Documents
66

77
.. default-domain:: mongodb
88

9-
You can edit existing documents in your collection. When you edit
10-
a document, |compass-short| performs a
11-
:manual:`findAndModify </reference/method/db.collection.findAndModify/>`
12-
operation to update the document.
9+
You can edit existing documents in your collection.
10+
11+
.. include:: /includes/fact-modify-findOneAndUpdate.rst
12+
13+
.. include:: /includes/fact-modify-findOneAndReplace.rst
14+
1315

1416
Limitations
1517
-----------
@@ -36,7 +38,6 @@ documents in List, JSON, or Table view:
3638
:figwidth: 620px
3739
:alt: Document View Selection
3840

39-
|
4041

4142
.. tabs::
4243

@@ -47,68 +48,77 @@ documents in List, JSON, or Table view:
4748
icon:
4849

4950
.. figure:: /images/compass/edit-doc.png
50-
:figwidth: 696px
51+
:figwidth: 696px
52+
:alt: Document Edit Selection
5153

5254
After you click the pencil icon, the document enters edit mode:
5355

5456
.. figure:: /images/compass/edit-doc2.png
55-
:figwidth: 696px
57+
:figwidth: 696px
58+
:alt: Document Edit Mode
5659

5760
You can now make changes to the fields, values, or data types
5861
of values.
5962

6063
Delete Fields
61-
-------------
64+
~~~~~~~~~~~~~
6265

6366
To delete a field from a document, click the ``x`` icon to the
6467
left of the field:
6568

6669
.. figure:: /images/compass/edit-doc3.png
67-
:figwidth: 740px
70+
:figwidth: 740px
71+
:alt: Document Deletion
6872

6973
Once selected, the field is marked for removal and appears
7074
highlighted in red:
7175

7276
.. figure:: /images/compass/edit-doc4.png
73-
:figwidth: 740px
77+
:figwidth: 740px
78+
:alt: Document Removal View
7479

7580
Add New Fields
76-
--------------
81+
~~~~~~~~~~~~~~
7782

78-
To add a new field in the document, hover over the row number in
79-
the dialog (the row number is not part of the document but the
80-
dialog display) and click on the plus sign add a new field after
81-
the field.
83+
To add a new field in the document after an existing field, hover
84+
over the row number in the dialog and click on the plus sign. The
85+
row number is not part of the document but is part of the dialog display.
8286

8387
You can also add a new field at the end of the document by
8488
pressing the tab key when your text cursor is in the value of the
8589
last document field.
8690

8791
Modify an Existing Field
88-
------------------------
92+
~~~~~~~~~~~~~~~~~~~~~~~~
8993

90-
You can modify documents by clicking on existing field names or
91-
values and making changes. In this example, the flight status was
94+
To modify documents, click on existing field names or
95+
values and make changes. In this example, the flight status was
9296
changed from ``L`` to ``M``. Changed fields appear highlighted in
9397
yellow:
9498

9599
.. figure:: /images/compass/update-field.png
96-
:figwidth: 740px
100+
:figwidth: 740px
101+
:alt: Document Update View
102+
103+
.. include:: /includes/fact-modify-findOneAndUpdate.rst
104+
105+
.. include:: /includes/fact-modify-prevent-overwrites.rst
97106

98107
Save Changes
99-
------------
108+
~~~~~~~~~~~~
100109

101110
When you are finished editing the document, click the ``Update``
102111
button to commit your changes.
103112

104113
Revert a Change
105-
---------------
114+
~~~~~~~~~~~~~~~
106115

107116
To revert changes to a document, hover over the edited field
108117
and click the :guilabel:`revert icon` which appears to the left
109118
of the field's line number.
110119

111120
.. figure:: /images/compass/revert-doc-list-view.png
121+
:alt: Revert Document in List View
112122

113123
.. tab:: JSON View
114124
:tabid: json
@@ -121,13 +131,14 @@ documents in List, JSON, or Table view:
121131
icon:
122132

123133
.. figure:: /images/compass/document-edit-json.png
124-
:figwidth: 696px
134+
:figwidth: 696px
135+
:alt: Document Edit Selection in JSON View
125136

126137
After you click the pencil icon, the document enters edit mode.
127138
You can now add, remove, and edit field values by modifying
128139
the JSON document.
129140

130-
By default, embedded objects and arrays are hidden. To expand
141+
By default, this view hides embedded objects and arrays. To expand
131142
embedded objects and array elements, hover over the target
132143
document and click the top arrow on the left side of the document.
133144

@@ -136,7 +147,11 @@ documents in List, JSON, or Table view:
136147

137148
.. figure:: /images/compass/expand-doc-json-view.png
138149
:figwidth: 696px
139-
:alt: Expand embedded objects JSON
150+
:alt: Expand embedded objects in JSON view
151+
152+
.. include:: /includes/fact-modify-findOneAndReplace.rst
153+
154+
.. include:: /includes/fact-modify-prevent-overwrites.rst
140155

141156
.. tab:: Table View
142157
:tabid: table-view
@@ -146,14 +161,20 @@ documents in List, JSON, or Table view:
146161

147162
.. figure:: /images/compass/table-view-modify.png
148163
:figwidth: 696px
164+
:alt: Document Edit Selection in Table View
149165

150166
After you click the pencil icon, the document enters edit mode:
151167

152168
.. figure:: /images/compass/document-edit-table.png
153-
:figwidth: 696px
169+
:figwidth: 696px
170+
:alt: Document Edit Mode in Table View
171+
172+
.. include:: /includes/fact-modify-findOneAndUpdate.rst
173+
174+
.. include:: /includes/fact-modify-prevent-overwrites.rst
154175

155176
Delete Fields
156-
-------------
177+
~~~~~~~~~~~~~
157178

158179
To delete a field from a document:
159180

@@ -164,7 +185,7 @@ documents in List, JSON, or Table view:
164185
#. Click :guilabel:`Update` to confirm your changes.
165186

166187
Add New Fields
167-
--------------
188+
~~~~~~~~~~~~~~
168189

169190
To add a new field to the document:
170191

@@ -179,7 +200,7 @@ documents in List, JSON, or Table view:
179200
#. Click :guilabel:`Update` to confirm your changes.
180201

181202
Revert a Change
182-
---------------
203+
~~~~~~~~~~~~~~~
183204

184205
While modifying a document, you have the option to revert changes
185206
made to a field prior to saving the modified document.
@@ -188,6 +209,7 @@ documents in List, JSON, or Table view:
188209
right side of the edited table element.
189210

190211
.. figure:: /images/compass/revert-doc-table-view.png
212+
:alt: Document Revert Changes in Table View
191213

192214
Cancel Changes
193215
--------------
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
When you edit a document in JSON view, |compass-short| performs a
2+
:manual:`findOneAndReplace </reference/method/db.collection.findOneAndReplace/>`
3+
operation and replaces the document.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
When you edit a document in List or Table view, |compass-short| performs a
2+
:manual:`findOneAndUpdate </reference/method/db.collection.findOneAndUpdate/>`
3+
operation and updates only those fields that you have
4+
changed.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
If |compass-short| detects that you have changed fields
2+
that were modified outside of |compass-short|, it notifies you, preventing
3+
you from accidentally overwriting the changes made outside of |compass-short|.
4+
You can choose to proceed and replace the document by clicking :guilabel:`Update`,
5+
or cancel your changes.

0 commit comments

Comments
 (0)