DatabaseAPI()

An API whose response is computed inside a transaction.

new DatabaseAPI()

Members

CONTEXT_OPTIONS

Options to pass the Firestore db.Context which wraps computeResponse().

IS_READ_ONLY

Whether this API can only read from Firestore. If false, the API's computeResponse() method will run in a Firestore transaction.

Methods

async, protected postCommit(respData) → {*}

Called after the transaction commits (and ONLY if it commits successfully). May alter the response by returning a new response value, or throwing RequestDone.
Parameters:
Name Type Description
respData * the response data
Returns:
* - the (possibly updated) response data

async, protected preCommit(respData) → {*}

Called just before the transaction ATTEMPTS to commit. May alter the response by returning a new response value, or throwing RequestDone. Throwing an error will be propagated and handled by Transaction.run(), and will prevent the transaction from committing (unless the error is retryable).
Parameters:
Name Type Description
respData * the response data
Returns:
* - the (possibly updated) response data

async, protected preTxStart()

Called just before the transaction starts. Useful to do async computation outside the transaction (reducing the window for contention).