Run Queries atomically

I have a scenario where I need to update a document in the bucket (using upsert) and delete another document(using remove) in the same bucket.
But I want both the update and delete should be successful or neither is successful.

How to achieve this?
I am using Couchbase java SDK.

Please see these. Cisco explains how they do this with Couchbase.