Skip to content

Commit 6c9dde0

Browse files
authored
add note about the similarity of $set commands (#6143) (#6208)
* add note about the similarity of $set commands * fix formatting
1 parent 1b06458 commit 6c9dde0

File tree

1 file changed

+17
-0
lines changed
  • source/reference/operator/update

1 file changed

+17
-0
lines changed

source/reference/operator/update/set.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,23 @@ After updating, the document has the following values:
149149
ratings: [ { by: 'Customer007', rating: 4 } ]
150150
}
151151

152+
.. important::
153+
154+
The above code uses ``dot notation`` to update the ``make`` field of the
155+
embedded ``details`` document. The code format looks similar to the following
156+
code example, which instead *replaces the entire embedded document*, removing
157+
all other fields in the embedded ``details`` document:
158+
159+
.. code-block:: javascript
160+
:copyable: false
161+
162+
db.products.updateOne(
163+
{ _id: 100 },
164+
{ $set: { details:
165+
{make: "Kustom Kidz"}
166+
}
167+
})
168+
152169

153170
Set Elements in Arrays
154171
~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)