Hello,
Could you please help me to construct an update for an attribute of an object withing an array only for those objects that have a specific value in a specific attribute?
My document:
{
“work”: “work_1”,
“territory”: [
{
“country”: {
“value”: “UK”,
“id”: “1111”
},
“status”: “Pending”,
“selected”: false
},
{
“country”: {
“value”: “FR”,
“id”: “1112”
},
“status”: “Confirmed”,
“selected”: false
}
]
}
So I need to update all documents (with above structure) where country code is UK, I need to change everywhere UK to GB .
Below n1ql I tyried to create is changing everywhere value of country object to GB and deletes somehow “selected” and “status” attributes.
UPDATE
dept
SET
territory=(ARRAY OBJECT_PUT(t.country, “value”, “GB”
) FOR t IN territory END
)
Can someone please help me to correct it? Thanks in advance.