Mutiple Upsert in Couchbase SDK 3

How is multiple upsert supported in Couchbase SDK3 ?
Currently i am on SDK 2 and planning to migrate to SDK 3 and looking for the support for the below code in SDK 3

                .upsert("a", entity.getA)
                .upsert("b", entity.getB)

Hi @rishabh_katyal

So you want to do a Sub-Document mutation on a single document, mutating two of its fields? You can still do that in SDK3, the syntax is just a little different. Please see this example in the docs: Sub-Document Operations with the Java SDK | Couchbase Docs

@graham.pople Yes, thats correct.

The example is not very clear

Your example would look like this in SDK3:

        MutateInResult result = collection.mutateIn(campaignEntity.getId(), Arrays.asList(
                MutateInSpec.upsert("a", entity.getA),
                MutateInSpec.upsert("b", entity.getB)));

1 Like