Answers for "mongodb add element to array"

2

mongodb add to array if not exists

db.tags.update(
    {name: 'sport'},
    {$addToSet: { videoIDs: "34f54e34c" } }
);
Posted by: Guest on October-22-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
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
1

mongodb add array to set

$addToSet: {
	$each: [1, 2, 3, 4]
}
Posted by: Guest on October-15-2021
3

mongodb push to arry in update

db.collection.update({_id:xx}, {$pop:{letters : -1}})
Posted by: Guest on March-22-2020
-1

how to push array in mongodb

pushing to mongodb
Posted by: Guest on October-08-2021

Code answers related to "mongodb add element to array"

Browse Popular Code Answers by Language