Update query for dynamic field

Hi I’m new to N1QL, can anyone help me with update query
Below is the document structure.

{
"id" : "0123",
"subjects: {
"maths":{
"marks" :[{
"First" : 34,
"Second" : 56
}
]
},
"science":{
"marks" :[{
"First" : 54,
"Second" : 76
}
]
}
} 
}

Want to update the Second field in marks (array of objects) in subject Object whenever it is maths.

To set to 100 for example:

UPDATE myBucket b
SET m.Second = 100 FOR m IN b.subjects.maths.marks END
WHERE ...

HTH.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.