我正在尝试编辑/更新单个数组的现有数据,不明白我在这里错过了什么语法
..........
name: String,
technologies:{
server:[{
name: String,
version: Number,
note: String,
status: Boolean
}]
}
..........
我的代码
exports.editTechnologyPost = function(req, res){
Project.findOneAndUpdate(
{ "name" : req.params.name, "technologies.server._id": req.params.id },
{ "$set": {
'technologies.$.server.$.name': req.body.name,
'technologies.$.server.$.version': req.body.version,
'technologies.$.server.$.note': req.body.note,
'technologies.$.server.$status': req.body.status
} }, { new: true },
function(err, obj) {
}
)
}