UPDATE SET FOR IN WHEN END chain

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

The last example (end of the page) in the link you posted covers nested arrays.

UPDATE `travel-sample`
SET v2.bbb = "test !!!!!!!"
     FOR v2 IN v1.aaa
               FOR v1 IN  reviews
      WHEN v2.id="b2" AND v1.author="Nedra Cronin" END
WHERE META().id="hotel_10063"
LIMIT 1 RETURNING reviews

Each nested needs FOR , The syntax you used is for two arrays iterating same time same position.

update:

set-clause:

update-for:

unset-clause:

If different arrays you can use different SET/UNSET
If same array position you can reconstruct OBJECT using object functions,

If you need help post the original /expected documents with what bases you want update will suggest it.

Thanks vsr1, here is the truncated form of the “hotel_10063” doc in the standard travel-sample bucket after I successfully ran the first UPDATE statement, which inserted the attribute “aaa” array of objects to the second object under the “reviews” array.

I am trying to change the string value of the “bbb” attribute located in the second object in the “aaa” array where the “id” attribute equals “b2”. I am having a hard time following the very last example on the link I originally posted that you pointed out – for my query to work, do I have to create a new index? I originally did not think I would because the FOR chain is not in the predicate…

{
  "address": "6 rue aux Juifs",
  "alias": "Les Rouges Gorges",
  ...
  "price": "60 / 70 euros",
  "public_likes": [],
  "reviews": [
    {
      "author": "Blaise O'Connell IV",
      "content": "Staff need a bit ...",
      "date": "2015-12-02 09:11:19 +0300",
      "ratings": {
        "Cleanliness": 3,
        "Overall": 3,
        "Rooms": 3,
        "Service": 1,
        "Value": 3
      }
    },
    {
      "aaa": [
        {
          "bbb": "_21",
          "id": "a1"
        },
        {
          "bbb": "_22",
          "id": "b2"
        },
        {
          "bbb": "_23",
          "id": "c3"
        }
      ],
      "author": "Nedra Cronin",
      "content": "We ended up choosing the Holiday Inn because ...",
      "date": "2012-01-14 02:15:51 +0300",
      "ratings": {
        "Overall": 4
      }
    },
    {
      "author": "Marianna Schmeler",
      "content": "I must explain this history in order that ...",
      "date": "2015-11-29 16:27:44 +0300",
      "ratings": {
        "Cleanliness": 3,
        "Location": 1,
        "Overall": 4,
        "Rooms": 3,
        "Service": 5,
        "Sleep Quality": 3,
        "Value": 4
      }
    },
    ...
  ],
  "state": "Haute-Normandie",
  "title": "Giverny",
  "tollfree": null,
  "type": "hotel",
  "url": "http://givernyguesthouse.com/robin.htm",
  "vacancy": true
}

Actually the modified UPDATE statement you posted did exactly what I was looking for – thank you!