Update object in deep Nested Array

Hi Team,

I’ve a depts bucket which has documents like below. Each document in this bucket has nested array of objects (upto three nested level).

  [
    {
      dept : {
      -- level one
        label : [
          {
            -- level two
            priority : [
              {
                level : '1',
                levelProperties  : {
                  color: 'red',
                  -- level thre
                  data : [
                    {
                      deptType : 'x',
                      label : {
                        labelId : '222222',
                        isEdited : false
                      }
                    },
                    {
                      deptType : 'y',
                      label : {
                        labelId : '1111111',
                        isEdited : false
                      }
                    }
                  ]
                }   
              }
            ]
          }
        ]
      }
    },
    {
      dept : {
      -- level one
        label : [
          {
            -- level two
            priority : [
              {
                level : '1.1',
                levelProperties  : {
                  color: 'red',
                  -- level thre
                  data : [
                    {
                      deptType : 'x',
                      label : {
                        labelId : '222222',
                        isEdited : false
                      }
                    },
                    {
                      deptType : 'y',
                      label : {
                        labelId : '1111111',
                        isEdited : false
                      }
                    }
                  ]
                }   
              }
            ]
          }
        ]
      }
    },
  ]

I am trying to update isEdited property of label object in all documents if labelId of that object matches the id passed from UI.

I’ve followed this forum Update an attribute inside a array in a json docuemnt to achieve the scenario. But i could not able to update with my deep nested array

Thanks in Advance.

Updates any where (all matches) in the document

UPDATW depts AS d
SET f.isEdited = true  FOR f WITHIN d.label WHEN f.labelId = "222222"  AND v.isEdited = false END
WHERE ANY v WITHIN d.label SATISFIES  v.labelId = "222222" AND v.isEdited = false END;