Mutation state

class couchbase.mutation_state.MutationState(*docs: MutationResult, **kwargs: Any)

A set of mutation tokens a query, search or range scan is to be consistent with.

Pass it as the consistent_with option, and the service waits until it has seen every mutation in the set before it answers.

Parameters:
add_all(bucket: Any, quiet: bool = False) → bool

Add every mutation made through a bucket to the set.

Parameters:
  • bucket – The bucket the mutations were made through.

  • quiet – When True, a bucket with no mutations returns False rather than raising.

Returns:

True if at least one mutation was added, False if none was and quiet was given.

Return type:

bool

Raises:

MissingTokenException – If no mutation was added and quiet was not given.

add_mutation_token(mut_token: MutationToken | None) → None

Add a mutation token to the set.

Parameters:

mut_token – The token to add. Anything that is not a MutationToken is ignored.

add_results(*rvs: MutationResult, **kwargs: Any) → bool

Add the mutation tokens of the given results to the set.

A result carries a token only if mutation tokens are enabled on the connection, as they are by default.

Parameters:
  • *rvs – One or more results of mutations.

  • **kwargs – quiet: when True, a result with no token stops the adding and returns False rather than raising.

Returns:

True if every result’s token was added, False if a result had none and quiet was given.

Return type:

bool

Raises:

MissingTokenException – If no results are given, or a result has no token and quiet was not given.