1
我的数据如下,现在favoriteapi将有关键/值记录进出。Mongodb嵌套插入
我如何将数据插入到该嵌套元素
{
"firstname": "ram5656",
"lastname": "rahul",
"email": "[email protected]",
"password": "encrypt",
"favoriteapi" : [
{
"api_id" : "function",
"api_name" : "enterprise"
},
{
"api_id" : "data_subject_category",
"api_name" : "address"
},
{
"api_id" : "data_subject",
"api_name" : "address"
}
],
"is_active": true,
"create_ts": "2016-05-18T00:00:00.000Z",
"create_by": "[email protected]",
"update_ts": "2016-05-18T06:00:00.000Z",
"update_by": "[email protected]",
"lastlogin": "2016-05-01T00:00:00.000Z"
}
我想这
var updatedocument =
{
"api_id" : "sanket",
"api_name" : "sanket"
}
user.favoriteapi.insert(updatedocument, options);
,但没有运气。
我应该使用upsert吗?
谢谢文斯:) –