Array update using java client

How do I update a field for a nested array json input?
Works fine in N1QL, but not able to create using java api.

UPDATE bucketName as myBucket SET enroll.status=‘INACTIVE’ FOR enroll IN app.enrollList FOR app IN myBucket.apps when enroll.deviceInfo.deviceId=‘deviceId1002’ end

{
“apps”: [
{
“enrollList”: [
{
“deviceInfo” : {
},
status: “active”
}
]
}
]
}

Was finally able to resolve using the below, Is this the only alternative?
update(i(bucket.name()).as(“myBucket”))
.set(path(“enroll.status”), s(“INACTIVE”),
x(“FOR enroll IN app.enrollList FOR app IN myBucket.apps when enroll.deviceInfo.deviceId=‘DeviceId’ end”));

java client version: 2.4.5

Are you saying you’re looking for a completely fluent alternative? This may be something we need to look into adding. @daschl or @subhashni should be able to say.

thanks for replying back! Yes, I see there is a method which does for one level like

UpdateForClause.forIn…when…

but I couldn’t use it for nested array data structure, hence checking if there was an alternative available or just that it isn’t available in the java client yet.

Also after the update, how do I return the very same document (entire) which was updated? can’t I use the returning() method? or should it be a direct get call?