Answers for "insert item into list mongodb"

1

mongodb add multiple element to array

db.students.update(
   { name: "joe" },
   { $push: { scores: { $each: [ 90, 92, 85 ] } } }
)
Posted by: Guest on July-01-2020
6

mongodb push to arry in update

db.collection.update({_id:xx}, {$push:{letters : {$each:['first one'], $position:0}}})
Posted by: Guest on March-22-2020
0

insert item into list mongodb

db.col.update(
    { name: 'doc', 'list.id': 2 }, 
    {$push: {'list.$.items': {id: 5, name: 'item5'}}}
)
Posted by: Guest on December-05-2020

Browse Popular Code Answers by Language