Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

node js mongodb update nested object

//just read documentaion in source and see how to  use the $ sign !! 
myDataBase.updateOne({ 'project': 'test2', 'issues._id': new ObjectID('61006f2409a2524514d877ce') }, { $set: { 'issues.$.open': true, 'issues.$.updated_on': new Date() } })
//for  mongodb 4+ 
const ObjectId = require('mongodb').ObjectId;
Source by docs.mongodb.com #
 
PREVIOUS NEXT
Tagged: #node #js #mongodb #update #nested #object
ADD COMMENT
Topic
Name
3+1 =