TransactionSet

parasql.schema. TransactionSet

The TransactionSet class is a container for multiple related DataTable objects. Rows added to DataTables are INSERTed into the database, rows marked for delete in DataTables are deleted from the database, and changed DataValues are used to UPDATE the database. Saving a TransactionSet causes all changes to its DataTables to be saved to the database in a single transaction.

Constructor

new TransactionSet()

License:

Extends

  • Object

Methods

addNewDataTable(tableName) → {parasql.schema.DataTable}

Parameters:
Name Type Description
tableName string
Returns:

A newly created DataTable.

Type
parasql.schema.DataTable

discardChanges()

Tells each DataTable in this TransactionSet to discardChanges.

Description:
  • Tells each DataTable in this TransactionSet to discardChanges.

getDataTable(tableName) → {parasql.schema.DataTable}

Parameters:
Name Type Description
tableName string
Throws:

If the specified tableName cannot be found in this TransactionSet.

Type
Error
Returns:
Type
parasql.schema.DataTable

isDirty() → {boolean}

Returns:

True if this TransactionSet is dirty (contains unsaved changes).

Type
boolean

markAsSaved()

Tells each DataTable in this TransactionSet to markAsSaved.

Description:
  • Tells each DataTable in this TransactionSet to markAsSaved.

save(callbacknullable)

Cause this TransactionSet to attempt to save all changes to its DataTable objects since the change tracker was last reset.

Description:
  • Cause this TransactionSet to attempt to save all changes to its DataTable objects since the change tracker was last reset. New rows will be inserted, modified rows will be updated, and rows marked for delete will be deleted. All operations are performed within a single transaction and committed if successful and rolled back on error. If the save is successful, this TransactionSet will automatically be markAsSaved. This method does nothing if this TransactionSet is not dirty.

Parameters:
Name Type Attributes Description
callback function <nullable>

Optional function to be called after this save operation completes; the callback function will be passed a single parameter that is a JSON object with the following structure: {status:string, errorMessage:string} where status will be either OK or ERROR.