cosmos db api for mongo db facing issue for some commands

大憨熊 提交于 2019-12-23 04:40:39

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!