Pra*_*sha 8 javascript json azure mongodb azure-cosmosdb
{
"_id" : ObjectId("59660d4099c1e682e0992ced"),
"alpha" : [
{
"_id" : ObjectId("59660d4199c1e682e0992cee"),
"number" : 1,
"start_at" : ISODate("2017-07-12T11:51:28.895Z"),
"end_at" : ISODate("2017-08-12T11:51:28.895Z"),
"created_at" : ISODate("2017-07-12T11:51:29.346Z"),
"updated_at" : null
}
]
}
Run Code Online (Sandbox Code Playgroud)
我有一个上面的文档,我想在'alpha'数组的JSON元素中更新或更改字段'number'和'updated_at'.
我试过这个:
db.mycol.update({_id: ObjectId("59660d4099c1e682e0992ced"), alpha: {$elemMatch: {_id: ObjectId("59660d4199c1e682e0992cee")}}}, {$set: {"alpha.$.number": 2, "alpha.$.updated_at": new Date()}})
Run Code Online (Sandbox Code Playgroud)
它适用于普通的mongodb服务器.但是使用azure cosmosdb/mongodb它说好,但没有真正更新文档.我究竟做错了什么?