问题
I am using azure cosmosdb mongo api and unable to run bellow command on it. It runs fine when executed on locally hosted mongo service. Is there any way around for this?
db.getCollection('requests').update(
{claims: { $elemMatch: { id:1000 }}},
{$set:{"claims.$.billForMonth":"1"}}
)
My data is
{
"_id" : NumberLong(1000),
"location" : "pune",
"claims" : [
{
"id" : NumberLong(1000),
"type" : "broadband",
"billForMonth" : 4
}]
}
回答1:
I could reproduce the issue on my side, when I do the following update operatation, it indicates I have updated the data successfully.
But if I query the data, I find billForMonth
is not updated.
If I update a non-array field (such as location
field), it works fine.
db.testc1.update(
{claims: { $elemMatch: { id:1000 }}},
{$set:{"location":"pune1"}}
)
It seems that cosmos db:mongo api does not support Array Update now, this feature will be supported in future. You will find the following information in this article.
来源:https://stackoverflow.com/questions/44633843/cosmos-db-api-for-mongo-db-facing-issue-for-some-commands