Skip to content

Commit 9cef041

Browse files
authored
add note about the similarity of $set commands (#6143)
* add note about the similarity of $set commands * fix formatting
1 parent ce796a9 commit 9cef041

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
@@ -153,6 +153,23 @@ After updating, the document has the following values:
153153
ratings: [ { by: 'Customer007', rating: 4 } ]
154154
}
155155

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

157174
Set Elements in Arrays
158175
~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)