How to update a String with an Array in a document within Robo3T?

I am trying to change an element object that is within an array in a document on Robo3T.

The structure looks like this:

  {
    "_id" : ObjectId("1234"),
    "source" : "BW",
    "sourceTableName" : "lwtrmls",
    "tableName" : "tier",
    "type" : "main",
    "primaryKeys" : [ 
        {
            "sourceField" : "tier_id", // <~~~~ This is what I am trying to update!
            "reportingField" : "bw_id",
            "type" : "integer"
        }
    ]
}

Basically trying to change tier_id under primaryKeys and sourceField to trmls_id.

I have tried something like db.my_collection.update( {_id : "1234"}, {$set : {"primaryKeys.0.tier_id" : "trmls_id"}} ) and that does not seem to be working. Is there a clean way to do this?

14 thoughts on “How to update a String with an Array in a document within Robo3T?”

Leave a Comment