Updating multiple documents using Java couchbase SDK

372 views Asked by At

I am using java Couchbase sdk in my application. I want to update same path with same values for multiple documents. For example there is a key X with value Y in all these documents. I want to update the Key X to have the value Z.

I am using the Async bucket's query method and the query that I am using looks like this-

UPDATE default USE KEYS ["a","b","c"] SET X=Z

default is the bucket name

a,b,c are the document keys that I want to update.

My question here is does the sdk guarantees that either all of these keys will be updated or none of them. How do I know if all the documents were updated correctly?

1

There are 1 answers

0
vsr On

N1QL doesn't support transactions (Atomicity is at document level not statement/multi statement level). You should check out JAVA SDK transactions https://docs.couchbase.com/java-sdk/current/howtos/distributed-acid-transactions-from-the-sdk.html