c

com.couchbase.client.scala.transactions

TransactionAttemptContext

class TransactionAttemptContext extends AnyRef

Provides methods to allow an application's transaction logic to read, mutate, insert and delete documents.

These methods are blocking/synchronous. See ReactiveTransactionAttemptContext for the asynchronous version.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TransactionAttemptContext
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. def get(collection: Collection, id: String): Try[TransactionGetResult]

    Gets a document from the specified Couchbase collection matching the specified id.

    Gets a document from the specified Couchbase collection matching the specified id. If the document is not found, a com.couchbase.client.core.error.DocumentNotFoundException is raised.

    collection

    the Couchbase collection the document exists on

    id

    the document's ID

    returns

    a TransactionGetResult containing the document

  2. def insert[T](collection: Collection, id: String, content: T)(implicit serializer: JsonSerializer[T]): Try[TransactionGetResult]

    Inserts a new document into the specified Couchbase collection.

    Inserts a new document into the specified Couchbase collection.

    The insert is staged until the transaction is committed. No other actor will be able to see this inserted document until that point.

    This staged data effectively locks the document from other transactional writes until the attempt completes (commits or rolls back).

    collection

    the Couchbase collection in which to insert the doc

    id

    the document's unique ID

    content

    this can be of any type for which an implicit com.couchbase.client.scala.codec.Conversions.JsonSerializer can be found: a list of types that are supported 'out of the box' is available at these JSON docs

  3. def query(scope: Scope, statement: String, options: TransactionQueryOptions): Try[TransactionQueryResult]

    Runs a N1QL query and returns the result.

    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 generally cause the attempt to fail.

  4. def query(scope: Scope, statement: String): Try[TransactionQueryResult]

    Runs a N1QL query and returns the result.

    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 generally cause the attempt to fail.

  5. def query(statement: String, options: TransactionQueryOptions): Try[TransactionQueryResult]

    Runs a N1QL query and returns the result.

    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 generally cause the attempt to fail.

  6. def query(statement: String): Try[TransactionQueryResult]

    Runs a N1QL query and returns the result.

    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 generally cause the attempt to fail.

  7. def remove(doc: TransactionGetResult): Try[Unit]

    Removes the specified doc.

    Removes the specified doc.

    The remove is staged until the transaction is committed. That is, the document will continue to exist, and the rest of the Couchbase platform will continue to see it.

    This staged data effectively locks the document from other transactional writes until the attempt completes (commits or rolls back).

    doc

    the doc to be removed

  8. def replace[T](doc: TransactionGetResult, content: T)(implicit serializer: JsonSerializer[T]): Try[TransactionGetResult]

    Mutates the specified doc with new content.

    Mutates the specified doc with new content.

    The mutation is staged until the transaction is committed. That is, any read of the document by any Couchbase component will see the document's current value, rather than this staged or 'dirty' data. If the attempt is rolled back, the staged mutation will be removed.

    This staged data effectively locks the document from other transactional writes until the attempt completes (commits or rolls back).

    doc

    the doc to be updated

    content

    this can be of any type for which an implicit com.couchbase.client.scala.codec.Conversions.JsonSerializer can be found: a list of types that are supported 'out of the box' is available at these JSON docs

    returns

    the doc, updated with its new CAS value. For performance a copy is not created and the original doc object is modified.