Class ReactiveTransactionAttemptContext

java.lang.Object
com.couchbase.client.java.transactions.ReactiveTransactionAttemptContext

public class ReactiveTransactionAttemptContext extends Object
Provides methods to allow an application's transaction logic to read, mutate, insert and delete documents, as well as commit or rollback the transaction.
  • Method Details

    • get

      public Mono<TransactionGetResult> get(ReactiveCollection collection, String id)
      Gets a document with the specified id and from the specified Couchbase collection.

      If the document does not exist it will throw a DocumentNotFoundException.

      Parameters:
      collection - the Couchbase collection the document exists on
      id - the document's ID
      Returns:
      a TransactionGetResult containing the document
    • get

      public Mono<TransactionGetResult> get(ReactiveCollection collection, String id, TransactionGetOptions options)
      Gets a document with the specified id and from the specified Couchbase collection.

      If the document does not exist it will throw a DocumentNotFoundException.

      Parameters:
      collection - the Couchbase collection the document exists on
      id - the document's ID
      options - options controlling the operation
      Returns:
      a TransactionGetResult containing the document
    • insert

      public Mono<TransactionGetResult> insert(ReactiveCollection collection, String id, Object content)
      Inserts a new document into the specified Couchbase collection.
      Parameters:
      collection - the Couchbase collection in which to insert the doc
      id - the document's unique ID
      content - the content to insert
      Returns:
      the doc, updated with its new CAS value and ID, and converted to a TransactionGetResult
    • insert

      public Mono<TransactionGetResult> insert(ReactiveCollection collection, String id, Object content, TransactionInsertOptions options)
      Inserts a new document into the specified Couchbase collection.
      Parameters:
      collection - the Couchbase collection in which to insert the doc
      id - the document's unique ID
      content - the content to insert
      options - options controlling the operation
      Returns:
      the doc, updated with its new CAS value and ID, and converted to a TransactionGetResult
    • replace

      public Mono<TransactionGetResult> replace(TransactionGetResult doc, Object content)
      Mutates the specified doc with new content.
      Parameters:
      doc - the doc to be mutated
      content - the content to replace the doc with
      Returns:
      the doc, updated with its new CAS value. For performance a copy is not created and the original doc object is modified.
    • replace

      Mutates the specified doc with new content.
      Parameters:
      doc - the doc to be mutated
      content - the content to replace the doc with
      options - options controlling the operation
      Returns:
      the doc, updated with its new CAS value. For performance a copy is not created and the original doc object is modified.
    • remove

      public Mono<Void> remove(TransactionGetResult doc)
      Removes the specified doc.

      Parameters:
      doc - - the doc to be removed
    • query

      public Mono<TransactionQueryResult> query(String statement)
      Calls query() with default options.
    • query

      public Mono<TransactionQueryResult> query(String statement, TransactionQueryOptions options)
      Runs a N1QL query and returns the result.

      All rows are buffered in-memory.

      Raises CouchbaseException or an error derived from it on failure. The application can choose to catch and ignore this error, and the transaction attempt is allowed to continue. This differs from Key-Value operations, whose failure will cause the attempt to fail.

    • query

      public Mono<TransactionQueryResult> query(ReactiveScope scope, String statement)
      Runs a N1QL query and returns the result, with default parameters.

      All rows are buffered in-memory.

      This overload performs a 'scope-level query': that is, one in which a collection may be referenced by name in the query statement, without needing to specify the full bucket.scope.collection syntax.

      Raises CouchbaseException or an error derived from it on failure. The application can choose to catch and ignore this error, and the transaction attempt is allowed to continue. This differs from Key-Value operations, whose failure will cause the attempt to fail.

    • query

      public Mono<TransactionQueryResult> query(ReactiveScope scope, String statement, TransactionQueryOptions options)
      Runs a N1QL query and returns the result.

      All rows are buffered in-memory.

      This overload performs a 'scope-level query': that is, one in which a collection may be referenced by name in the query statement, without needing to specify the full bucket.scope.collection syntax.

      Raises CouchbaseException or an error derived from it on failure. The application can choose to catch and ignore this error, and the transaction attempt is allowed to continue. This differs from Key-Value operations, whose failure will cause the attempt to fail.