Namespace: transactions

transactions

Provides functions to open, commit, or rollback multi-statement transactions. The client must have been created for a user with the rest-writer role.

Methods


commit(txid)

Finishes a multi-statement transaction by applying the changes.
Parameters:
Name Type Description
txid string | transactions.Transaction a string transaction id or Transaction object identifying an open multi-statement transaction
Since:
  • 1.0

open(transactionName, timeLimit, withState) → {transactions.Transaction|string}

Creates a multi-statement transaction, providing a transactionId or Transaction object to pass to write, read, and remove functions before calling the transactions#commit or transactions#rollback function to finish the transaction.
Parameters:
Name Type Argument Description
transactionName string <optional>
a label to assign to the transaction for easier recognition in reports
timeLimit number <optional>
the maximum number of seconds that the transaction should run before rolling back automatically
withState boolean <optional>
whether to return a Transaction object that can track the properties of the transaction
Since:
  • 1.0
Returns:
either a Transaction object (the default) or string transactionId identifying the multi-statement transaction; returning a string transactionId is deprecated and will be removed in the next major release.
Type
transactions.Transaction | string

read(txid) → {object}

Reads the current state of a multi-statement transaction created with the transactions#open function.
Parameters:
Name Type Description
txid string | transactions.Transaction a string transaction id or Transaction object identifying an open multi-statement transaction
Since:
  • 1.0
Returns:
information about the transaction
Type
object

rollback(txid)

Finishes a multi-statement transaction by reverting the changes.
Parameters:
Name Type Description
txid string | transactions.Transaction a string transaction id or Transaction object identifying an open multi-statement transaction
Since:
  • 1.0

Type Definitions


Transaction

An object representing a multi-statement transaction on the server.
Type:
  • object
Since:
  • 1.0
Copyright (c) 2020 MarkLogic Corporation Documentation generated by JSDoc 4.0.0 on 2024-08-19T23:06:48-07:00 using the DocStrap template.