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

Viewed 2462
{
    "_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?

1 Answers
Related