(AZURE cosmosDB / mongoDB) Update fields of a specific element of an object in an array

{
    "_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 stated above and I would like to update or change the 'number' and 'updated_at' field in the JSON element from the 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 a regular mongodb server. But with azure cosmosdb / mongodb, he speaks normally, but doesn’t actually update the document. What am I doing wrong?

+6
source share
1 answer

update or change the field 'number' and 'updated_at' in the JSON element of the array 'alpha'

/ MongoDB Azure Cosmos DB: MongoDB API. , , Azure Cosmos DB: MongoDB API , .

enter image description here

, User Voice, .

+3

All Articles