我知道这已经被问过很多次了,但是我似乎找不到答案,即如何在嵌套数组中更新但在没有id的嵌套数组中进行对象更新?
const hasil = await Setting.update(
{ _id: Id, 'value.name': req.body.name },
{ "$set": { 'value.value': req.body.value } }
)
{
"_id" : 1234567,
"key" : "version",
"name" : "Collection Version",
"value" : [
{
"name" : "categories",
"value" : 7
},
{
"name" : "tag",
"value" : 1
},
{
"name" : "article",
"value" : 3
},
],
}