Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

add multiple subdocument mongoose

#not duplicate value
db.getCollection('profilesservices').updateOne({_id: ObjectId("603ce3bf9323e811c86cb7c8")}, {
 $addToSet: {"jobPreferences.jobInterests": {$each: ["mobile developer", "backend developer"]} }    
})

# with duplicate value
db.getCollection('profilesservices').updateOne({_id: ObjectId("603ce3bf9323e811c86cb7c8")}, {
 $push: {"jobPreferences.jobInterests": {$each: ["mobile developer", "backend developer"]} }    
})
 
PREVIOUS NEXT
Tagged: #add #multiple #subdocument #mongoose
ADD COMMENT
Topic
Name
1+1 =