20 works

Append a Value to an Array


dashboard+ Project

Posted by @starbucks #javascript #nodejs

Code snippet:

db.students.update(
   { _id: 1 },
   { $push: { scores: 89 } }
)
content_copyCopy to Clipboard

More details:

The processing of the push operation with modifiers occur in the following order, regardless of the order in which the modifiers appear: Update array to add elements in the correct position. Apply sort, if specified. Slice the array, if specified. Store the array.

Code snippet source:

https://docs.mongodb.com/manual/reference/operator/update/push/

>> Browse more code snippets

more_vert