Template
single collection
multiple collections
mgodatagen
update
indexe
explain
Stage
Database
bson
mgodatagen
[{"user":"1","cart":[{product:"2",amount:1,price:10}]}]
Query
db.collection.update({$and:[{user:"1"},{"cart.product":{$nin:["1"]}}],},{$push:{cart:{product:"1",amount:1,price:10}}})
Result