使用Java Couchbase SDK 更新多个文档

huangapple go评论98阅读模式
英文:

Updating multiple documents using Java couchbase SDK

问题

我在我的应用程序中使用Java Couchbase SDK。我想要为多个文档的相同路径更新相同的值。例如,所有这些文档中都有一个键X,其值为Y。我想要将键X的值更新为Z

我正在使用异步存储桶的query方法,我使用的查询如下所示-

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

"default"是存储桶名称。

a、b、c是我想要更新的文档键。

我的问题是,SDK是否保证要么更新所有这些键,要么不更新任何键。我如何知道所有文档是否被正确更新?

英文:

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

得分: 2

N1QL不支持事务(原子性是在文档级别上,而不是语句/多语句级别)。您应该查看JAVA SDK事务,链接:https://docs.couchbase.com/java-sdk/current/howtos/distributed-acid-transactions-from-the-sdk.html

英文:

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

huangapple
  • 本文由 发表于 2020年10月6日 14:54:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/64220736.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定