Answers for "mongodb append 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
1

mongodb add array to set

$addToSet: {
	$each: [1, 2, 3, 4]
}
Posted by: Guest on October-15-2021
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
-1

how to push array in mongodb

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

Browse Popular Code Answers by Language