Tx

Tx

Transaction wrapper class, a public API for client transaction

Methods

(async) call(endpoint, …args) → {Promise.<*>}

Source:

Call a remote procedure (in transaction block)

Sync function only, use HClient#wait to wait for async function

Parameters:
Name Type Attributes Description
endpoint string

procedure name

args * <repeatable>

array of arguments, will be JSON serialized

Returns:

returns procedure results if any

Type
Promise.<*>

(async) commit() → {Promise.<void>}

Source:

Commit the transaction, closes the transaction block

Returns:
Type
Promise.<void>

(async) query(query, paramsopt) → {Promise.<Array.<object>>}

Source:

Run SQL query (in transaction block)

Parameters:
Name Type Attributes Description
query string

SQL query string

params Array.<*> <optional>

array of query parameters

Returns:

array of results

Type
Promise.<Array.<object>>

(async) rollback() → {Promise.<void>}

Source:

Rollback the transaction, closes the transaction block

Returns:
Type
Promise.<void>

(async) run(func, …args) → {Promise.<void>}

Source:

Run function in a server context (in transaction block)

Sync function only, use HClient#wait to wait for async function

Note: return value will be ignored!

Parameters:
Name Type Attributes Description
func function

arbitrary function

args * <repeatable>

function arguments, will be JSON serialized

Returns:
Type
Promise.<void>