我的貓鼬對象:貓鼬 - 推到對象
{
"_id" : "568ad3db59b494d4284ac191",
"name" : "MyCompany",
"description": "whatever"
"items" : [
{
"_id" : "568ad3db59b494d4284ac19f",
"fields" : {
"Name" : "Item1",
"Internal ID" : "ID00042",
"tags" : [
{
"Description" : "Tag1",
"Level" : 2
},
{
"Description" : "Tag2",
"Level" : 3
}
]
}
}, {
"_id" : "568ad3db59b494d4284ac19f",
"fields" : {
"Name" : "Item2",
"Internal ID" : "ID00043",
"tags" : [
{
"Description" : "Tag1",
"Level" : 5
},
{
"Description" : "Tag5",
"Level" : 1
}
]
}
}, {..}
]
}
我需要按以下標籤:
var obj = {
"Description" : "myDescription",
"Level" : 3
};
爲以下項目的標籤陣列:
var internal_id = "ID00102";
我的嘗試不起作用:
Company.findOneAndUpdate(
{ "_id": "568ad3db59b494d4284ac191", "items.fields['Internal ID]": internal_id },
{
"$push": {
"tags": thetag
}
},
function(err,doc) {
if (err) res.status(500).send(err);
return res.status(200).send(doc);
}
);