Skip to content

project.transaction

Begin, commit, cancel, and renew project transactions.

5 functions / 1 types

Index

FunctionDescription
beginOpens a transaction and returns its id. An expired lease discards its writes. Call RenewLease before expiry to keep the transaction open.
cancelEnds the transaction matching id as canceled, discarding its writes. Errors when no transaction with that id is open, or when a concurrent Commit or Cancel already finalized it.
commitEnds the transaction matching id as committed. Errors when no transaction with that id is open, or when a concurrent Commit or Cancel already finalized it.
forceCancelCancels the open transaction without its id. This can cancel another caller’s transaction. Errors when no transaction is open. Prefer Cancel when the id is known.
renewLeaseExtends an unexpired transaction by its original lease duration.
TypeDescription
TransactionModePolicy for operations submitted while a transaction is open.

begin

begin(args: { leaseSeconds?: number; mode: ProjectTransactionTransactionMode }, transactionId?: string): Promise<string>

Opens a transaction and returns its id. An expired lease discards its writes. Call RenewLease before expiry to keep the transaction open.

Returns Promise<string>.

leaseSeconds optional : number

Lease duration in seconds. Defaults to 60. Must be finite and between 0.001 and 86400.

mode : ProjectTransactionTransactionMode

Whether untagged operations are absorbed by this transaction.

transactionId optional : string

cancel

cancel(args: { id: string }, transactionId?: string): Promise<void>

Ends the transaction matching id as canceled, discarding its writes. Errors when no transaction with that id is open, or when a concurrent Commit or Cancel already finalized it.

Returns Promise<void>.

id : string

The transaction to end (hyphenated UUID string).

transactionId optional : string

commit

commit(args: { id: string }, transactionId?: string): Promise<void>

Ends the transaction matching id as committed. Errors when no transaction with that id is open, or when a concurrent Commit or Cancel already finalized it.

Returns Promise<void>.

id : string

The transaction to end (hyphenated UUID string).

transactionId optional : string

forceCancel

forceCancel(transactionId?: string): Promise<void>

Cancels the open transaction without its id. This can cancel another caller’s transaction. Errors when no transaction is open. Prefer Cancel when the id is known.

Returns Promise<void>.

transactionId optional : string

renewLease

renewLease(args: { id: string }, transactionId?: string): Promise<void>

Extends an unexpired transaction by its original lease duration.

Returns Promise<void>.

id : string

transactionId optional : string

TransactionMode

Enum

Policy for operations submitted while a transaction is open.

Shared (default) includes every operation. Private accepts only operations tagged with this transaction’s ID and rejects others with StatementError.TransactionNotAdmitted.

Private = 1

Shared = 0