1//Mongo insert many example
2 db.products.insertMany( [
3 { item: "card", qty: 15 },
4 { item: "envelope", qty: 20 },
5 { item: "stamps" , qty: 30 }
6 ] );
7//mongoose
8const Product = mongoose.model('Product', productSchema);
9Product.insertMany([
10 { item: "card", qty: 15 },
11 { item: "envelope", qty: 20 },
12 { item: "stamps" , qty: 30 }
13 ])
14
1// With { $push: { field: element } }
2
3// Example:
4const elementToPush = { a: 1, b: 2 };
5const body = { $push: { arrayField: elementToPush } };
6model.patch(id, body);
7