Module: PostData

Manages data storing
Source:

Classes

BasicMessage
MaxCacher
PostData
PostData

Members

(inner, constant) DataRow

{DataRow}
Source:

Methods

(inner) calcAutoId(r, autoIncrementProperty) → {promise}

Calculates an autoincrement column checking that there is no other rows with that key in table
Parameters:
Name Type Description
r ObjectRow
autoIncrementProperty AutoIncrementColumn ({DataRow} r, {string} columnName, {DataAccess} conn}
Source:
Returns:
//resolves true if it was a regular auto increment fields, false if it was a custom one
Type
promise

(inner) doPost(options) → {Promise.<{canIgnore:boolean, Array.<checks:BasicMessage>, data:DataSet}>}

Saves a dataSet and return empty list if successful or a list of messages if they have to be verified before effectively committing changes. If successfull, also returns saved DataSet
Parameters:
Name Type Description
options object
Properties
Name Type Attributes Default Description
isolationLevel string <optional>
DataAccess.isolationLevels.readCommitted
optimisticLocking OptimisticLocking <optional>
previousRules BusinessLogicResult <optional>
Source:
Returns:
Type
Promise.<{canIgnore:boolean, Array.<checks:BasicMessage>, data:DataSet}>

(inner) doPost(options) → {Object}

Saves a dataSet and return empty list if successful or a list of messages if they have to be verified before effectively committing changes.
Parameters:
Name Type Description
options object
Properties
Name Type Attributes Default Description
isolationLevel string <optional>
DataAccess.isolationLevels.readCommitted
optimisticLocking OptimisticLocking <optional>
previousRules BusinessLogicResult <optional>
Source:
Returns:
Type
Object

(inner) getMax(r, column, selectors, filter, expr) → {Promise.<int>}

Get the max for an expression eventually getting it from cache or giving null if reasonably there is no row on that match the filter If there is no selector, then the result can be taken from cache if a query with same parameters has already be done.
Parameters:
Name Type Description
r ObjectRow objectRow for which evaluate the max
column string column to evaluate
selectors Array.<string> //selector fields for the calculation
filter sqlFun //filter to apply
expr sqlFun //expression to evaluate
Source:
Returns:
Type
Promise.<int>

(inner) getMessage Gets the message of the rule() → {string}

Source:
Returns:
Type
string

(inner) getSqlStatements(changedRows, optimisticLocking) → {Deferred}

Gets an array of changed rows and returns a sequence of sql command that does the post.
Parameters:
Name Type Description
changedRows Array.<DataRow>
optimisticLocking OptimisticLocking
Source:
Returns:
Deferred is notified with n sets of (rows,sql) where sql is the sql command used to save rows. This is useful if some error is returned, to evaluate messages. Saving stops as soon as an error occurs.
Type
Deferred

(inner) physicalPostBatch(conn, optimisticLocking) → {*}

Runs a sequence of db commands in order to save an array of rows
Parameters:
Name Type Description
conn DataAccess
optimisticLocking OptimisticLocking
Source:
Returns:
Resolved promise if all ok, rejected promise if errors
Type
*

(inner) promiseParallel(tasks)

Parameters:
Name Type Description
tasks Array.<function()>
Source:

(inner) promiseWaterfall(tasks) → {Promise}

Builds a chained function, chaining each the Deferred function with "then"
Parameters:
Name Type Description
tasks Array.<Deferred> each task is a function that returns a deferred. Not the deferred itself!
Source:
Returns:
Type
Promise

(inner) reselect(row) → {*}

Reads again a row from db
Parameters:
Name Type Description
row ObjectRow
Source:
Returns:
Type
*

(inner) reselectAllViews() → {*}

Read all changed view rows from db
Source:
Returns:
Type
*

(inner) resolve() → {Deferred}

Resolve the promise with result, and do the necessary cleanup: rollback transaction if a transaction is open, and close connection if the connection is open. If further errors arise, add them to checks as dbErrors
Source:
Returns:
Type
Deferred

(inner) setMessage Sets the message of the rule() → {*}

Source:
Returns:
Type
*