I was able to successfully run the following:
UPDATE `travel-sample`
SET v1.aaa=[{"bbb":"_21","id":"a1"},{"bbb":"_22","id":"b2"},{"bbb":"_23","id":"c3"}]
FOR v1 IN reviews WHEN v1.author="Nedra Cronin" END
WHERE META().id="hotel_10063"
LIMIT 1 RETURNING reviews
The documentation states that you can chain FOR clauses together with the following syntax:
FOR variable (IN | WITHIN) path (, variable (IN | WITHIN) path)* [WHEN condition ] END
(SOURCE: https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/update.html )
My attempt at chaining the FOR clause within an UPDATE statement executes without error, but no edits to the record occur:
UPDATE `travel-sample`
SET v2.bbb = "test !!!!!!!"
FOR v1 IN reviews, v2 IN v1.aaa WHEN v2.id="b2" AND v1.author="Nedra Cronin" END
WHERE META().id="hotel_10063"
LIMIT 1 RETURNING reviews
Is there a way to edit specific object fields nested within multiple arrays? I cannot find any examples that do this.
Thanks!
George