Couchbase Java SDK subdocument mutation

95 Views Asked by At

Hi Im running couchabse server 7.1.3 docker container and trying to use the 3.3.4 couchbase java sdk version. I am facing an issue while performing subdocument mutation using the upsert command.

The issue I am facing is when I use the collection.mutateIn() method to perform a subdocument mutation using the upsert command, I am expecting to get the result of the operation as a MutateInResult object. when I try to use the MutateInResult.contentAs(0, String.class) to see the response I get the Index 0 is invalid error. I see that the operation as in is successful in the DB, I can see the desired json path has the updated value.

P.S: I only have a single mutation to perform which is the upsert command.

can someone please help if I am missing something here?

1

There are 1 best solutions below

0
On

A MutateInResult only has content for the result of increment and decrement mutations. In those two cases, the content is the new counter value, which you can access using result.contentAs(index, Long.class).

For all other types of subdocument mutations, the result does not include any content.