{
"_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
}
]
}
I have a document as above and I would like to update or change the field 'number' and 'updated_at' in a JSON element of 'alpha' array.
I tried this:
db.mycol.update({_id: ObjectId("59660d4099c1e682e0992ced"), alpha: {$elemMatch: {_id: ObjectId("59660d4199c1e682e0992cee")}}}, {$set: {"alpha.$.number": 2, "alpha.$.updated_at": new Date()}})
It works fine with normal mongodb server. But with azure cosmosdb/mongodb it says ok but doesn't really update the document. What am I doing wrong?
update or change the field 'number' and 'updated_at' in a JSON element of 'alpha' array
Not all of MongoDB's query syntax / capabilities are implemented in Azure Cosmos DB: MongoDB API. Based on my test, It seems that Azure Cosmos DB: MongoDB API does not support Array Update now, this feature will be supported in future.
If possible, you can create an item on User Voice to give a feedback.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With