📜  node js mongodb 更新嵌套对象 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:25.283000             🧑  作者: Mango

代码示例1
//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;