Updating nested array n1ql

The sample doc, I am trying to work with is:

{
   "name": "level1",
   "childLevel1": [
    {
       "name": "level2",
       "childLevel2": [
       {
          "name": "level3",
          "childLevel3": [
          {
               "name": "level4",
               "attribute1": "data"
          }
          ]
        }
        ]
     }
     ]
}

What we want to do is, with n1ql add one more array element to “childLevel3”. I have tried the reference to https://developer.couchbase.com/documentation/server/4.5/n1ql/n1ql-language-reference/update.html

I was able to add a regular attribute to childLevel2 but after that it was not working. This is the query I have been trying out.

Update sample
set child2.childLevel3 = ARRAY_PUT(child2.childLevel3, {'attribute' : 'data2'})
FOR child2 in child1.childLevel2 when child2.name == "level3" END
for child1 in childLevel1 when childLevel1.name == 'level2' END
WHERE name == 'level1'

But it gives me error on parsing, I tried other ways too but nothing works.

Hi @ashishgupta,

I answered this on Stack Overflow. http://stackoverflow.com/questions/42164004/updating-nested-array-n1ql/42168725#42168725