$each array monoose code example
Example 1: add in to array mongoose
// With { $push: { field: element } }
// Example:
const elementToPush = { a: 1, b: 2 };
const body = { $push: { arrayField: elementToPush } };
model.patch(id, body);
Example 2: how to spread an array in mongodb
db.inventory.update(
{ _id: 2 },
{ $addToSet: { tags: { $each: [ "camera", "electronics", "accessories" ] } } }
)