0

Embedded Update query works fine in mlab and atlas but not working in Cosmos DB:

My Collection structure:

{
    "_id" : ObjectId("5982f3f97729be2cce108785"),
    "password" : "$2y$10$F2P9ITmyKNebpoDaQ1ed4OxxMZSKmKFD9ipiU1klqio239c/nJcme",
    "nin" : "123",
    "login_status" : 1,
    "updated_at" : ISODate("2017-05-16T09:09:03.000Z"),
    "created_at" : ISODate("2017-05-16T06:08:47.000Z"),
    "files" : [ 
        {
            "name" : "abc",
            "updated_at" : ISODate("2017-05-16T06:08:48.000Z"),
            "created_at" : ISODate("2017-05-16T06:08:48.000Z"),
            "_id" : ObjectId("5982f3f97729be2cce108784")
        }
    ],
    "name" : "demo",
    "email" : "[email protected]",
    "phone" : "1231234",

}

My query is:

db.rail_zones.update(
  {'_id': ObjectId("5982f3f97729be2cce108785"),
   'files._id' : ObjectId("5982f3f97729be2cce108784")},
  { $set: {'files.$.name' : "Changed"}})

I get this response:

"acknowledged" : true,
"matchedCount" : 0.0,
"modifiedCount" : 0.0
2
  • what is the question? Commented Aug 3, 2017 at 10:38
  • What is the question? please explain.. Commented Aug 3, 2017 at 10:43

1 Answer 1

1

According to your description, I tested this issue on my side and found the Array Update could not work as expected. I assumed that the Array Update feature has not been implemented in the MongoDB Compatibility layer of Azure CosmosDB. Moreover, I found a feedback Positional array update via '$' query support talking about the similar issue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.