push element to array mongoose code example
Example: 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);
// With { $push: { field: element } }
// Example:
const elementToPush = { a: 1, b: 2 };
const body = { $push: { arrayField: elementToPush } };
model.patch(id, body);