0
更新我有收藏,結構如下圖所示, 我怎樣才能更新tags
場有:如何在MongoDB的
_id: 556c1c836e80082821f41d9f
_versions.id: 556c1c836e80082821f41da6
_versions._data._id: 556c71735ddb5010067f1beb
[{
"_id": ObjectId("556c1c836e80082821f41d9f");
"_name": "Product 1"
"_curr_version": ObjectId("556c1c836e80082821f41da6")
"_versions": [{
"_id": ObjectId("556c71735ddb5010067f1be6"),
"_data": [{
"_id": ObjectId("556c1cae82b9a3101787d20f"),
"_tags": ['sport', 'football']
}, {
"_id": ObjectId("556c71735ddb5010067f1beb"),
"tags": ['golf']
}
]
},
{
"_id": ObjectId("556c1c836e80082821f41da6"),
"_data": [{
"_id": ObjectId("556c1cae82b9a3101787d20f"),
"_tags": ['sport', 'swimming']
}, {
"_id": ObjectId("556c71735ddb5010067f1beb"),
"tags": ['tenis']
}
]
}
]
}]
爲這種多層次的更新使用的編程語言的代碼,仍然MongoDB中沒有提供這個一種查詢檢查[這](https://jira.mongodb.org/browse/SERVER-14164) – Yogesh
可能重複[Mongoose MongoDB:更新嵌套數組中的對象](http://stackoverflow.com/questions/ 27 260573/mongoose-mongodb-updates-objects-in-an-nested-array) – JME
我使用nodejs並使用mongosee驅動程序訪問mongodb。 – thinhnk