provides facilities to access a database without knowing exactly the database type or implementation details
- Source:
Classes
Members
(inner, constant) isolationLevels :string
All isolation level possible, may not be present in some db. In that case, the driver for that db will default into
some other similar available level depending on the DBMS capabilities.
Type:
- string
Properties:
Name | Type | Description |
---|---|---|
readUncommitted |
string | |
readCommitted |
string | |
repeatableRead |
string | |
snapshot |
string | |
serializable |
string |
- Source:
Methods
(inner) callSP(spName, paramList, rawopt, timeoutopt) → {Promise.<Array>}
call SP with a list of simple values as parameters. The SP returns a collection of tables.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
spName |
string | Name of the stored procedure | |
paramList |
Array.<object> | an array of all sp parameters, in the expected order | |
raw |
<optional> |
if true data will be returned as array of simple values, without calling objectify on it | |
timeout |
int |
<optional> |
- Source:
Returns:
(a sequence of arrays)
- Type
- Promise.<Array>
Example
DA.callSP('reset_customer',[1])
(inner) clone() → {Promise.<DataAccess>}
creates a duplicate of the connection, with same external user and connection string
- Source:
Returns:
promise to DataAccess
- Type
- Promise.<DataAccess>
(inner) close() → {Promise}
Closes the underlying connection.
Consecutive calls to this function results in a automatic nesting-opening level to be decreased.
the underlying connection is touched only when nesting-opening level goes from 1 to 0
If persisting is true, calling to close decrements nesting-opening level but has no other effect.
In that case, the connection will be automatically closed when DataAccess is destroyed
- Source:
Returns:
- Type
- Promise
(inner) destroy()
Destroy the DataAccess and closes the underlying connection
- Source:
(inner) doSingleDelete(options) → {Promise.<int>}
do a delete Command
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
- Source:
Returns:
- Type
- Promise.<int>
(inner) doSingleInsert(table, columns, values) → {Promise.<int>}
do an insert Command
Parameters:
Name | Type | Description |
---|---|---|
table |
string | |
columns |
string | array of column names |
values |
string | array of corresponding value |
- Source:
Returns:
- Type
- Promise.<int>
(inner) doSingleUpdate(options) → {Promise.<int>}
do an update Command
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
- Source:
Returns:
- Type
- Promise.<int>
(inner) getFormatter() → {SqlFormatter}
Gets a sql-formatter compatible with this Connection
- Source:
Returns:
- Type
- SqlFormatter
(inner) getPostCommand(r, optimisticLocking, environment) → {string|null}
gets the sql cmd to post a row to db. On Error, the command must return errNum
Parameters:
Name | Type | Description |
---|---|---|
r |
DataRow | |
optimisticLocking |
OptimisticLocking | |
environment |
Environment |
- Source:
Returns:
- Type
- string | null
(inner) getSecurity(conn)
Gets the security object and then calls the doneCallBack or errCallBack on errors
Parameters:
Name | Type | Description |
---|---|---|
conn |
Connection |
- Source:
(inner) mergeMultiSelect(selectList, ds, environmentopt) → {Promise}
Executes a multi-select given a list of select in input and merge all data into a specified DataSet
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
selectList |
Array.<Select> | ||
ds |
DataSet | ||
environment |
Environment |
<optional> |
if provided, security is applied |
- Source:
Returns:
- Type
- Promise
(inner) mergeRowIntoTable(table, r)
Merge a row into a table discarding any previous row with same primary key when present
Parameters:
Name | Type | Description |
---|---|---|
table |
DataTable | |
r |
object |
- Source:
(inner) multiSelect(options) → {Promise.<Array.<object>>}
Executes a multi-select given a list of select in input
DataAccess.multiselect
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
- Source:
Returns:
- Type
- Promise.<Array.<object>>
(inner) objectify(colNames, rows) → {Array}
Transforms raw data into plain objects
Parameters:
Name | Type | Description |
---|---|---|
colNames |
Array | |
rows |
Array |
- Source:
Returns:
- Type
- Array
(inner) open() → {Promise}
Opens the underlying connection.
Consecutive calls to this function results in a automatic nesting-opening level to be increased.
the underlying connection is touched only when nesting-opening level goes from 0 to 1
If `persisting` is true, calling to open increments nesting-opening level but has no other effect
- Source:
Returns:
- Type
- Promise
(inner) pagedSelect(opt, rawopt) → {Promise.<Array.<object>>}
Reads data from a table and returns a range of rows
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
object |
Properties
|
|||||||||||||||||||||||||||||||||||||||||||||||
raw |
boolean |
<optional> |
false | if raw, data returned is not objectified |
- Source:
Returns:
Array of objects with tableName set to the table name of data read
- Type
- Promise.<Array.<object>>
(inner) queryPackets(opt, packetSize, rawopt) → {Promise}
Gets rows from a db splitting them into packets. Packets are given as soon as they are available.
If raw is false, packet are like {set:number, rows:[array of objects]}
if raw is true, packet are like {set:number, meta:[array of column descriptors], rows:[array of array of values]}
the array of columns descriptors (meta) is enriched with a property tableName
if raw===false it is returned a series of {tableName: alias, set:set Number, rows: [array of plain objects]
if raw===true it is returned a series of {tableName: alias, meta:[array of column names], rows:[raw objects]
set numbers starts from 0
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
object |
Properties
|
|||||||||||||||||||||||||||||||||||||||||||||||
packetSize |
number | ||||||||||||||||||||||||||||||||||||||||||||||||
raw |
boolean |
<optional> |
false |
- Source:
Returns:
- Type
- Promise
(inner) readLastValue(query) → {Promise.<object>}
Read a value from database. If multiple values are returned, the last is taken
Parameters:
Name | Type | Description |
---|---|---|
query |
string | command to run |
- Source:
Returns:
- Type
- Promise.<object>
(inner) readSingleValue(options) → {Promise.<object>}
Read a value from database. If multiple values are returned, the first is taken
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | options has those fields:
Properties
|
- Source:
Returns:
- Type
- Promise.<object>
(inner) runCmd(cmd) → {Promise.<object>}
Read a value from database. If multiple values are returned, the first is taken.
It is similar to readSingleValue but accepts a generic sql command
Parameters:
Name | Type | Description |
---|---|---|
cmd |
string | should be a command resulting in a single value returned from db. Other output data will be ignored |
- Source:
Returns:
- Type
- Promise.<object>
(inner) runSql(cmd, rawopt) → {Promise.<(Array.<object>|{meta: Array.<string>, Array.<rows:object>})>}
Read a table from database. If multiple tables are returned, the first is taken.
It is similar to readSingleValue but accepts a generic sql command
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
cmd |
string | should be a command resulting in a table. Only first table got will be returned | ||
raw |
boolean |
<optional> |
false | if true, Data will not be objectified |
- Source:
Returns:
- Type
- Promise.<(Array.<object>|{meta: Array.<string>, Array.<rows:object>})>
(inner) secureGetLastError() → {string|null}
get lastError without destroying it
- Source:
Returns:
- Type
- string | null
(inner) select(opt, rawopt) → {Promise.<Array.<object>>}
Reads data from a table and returns the entire table read
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
object |
Properties
|
|||||||||||||||||||||||||||||||||||||||||||||||
raw |
boolean |
<optional> |
false | if raw, data returned is not objectified |
- Source:
Returns:
Array of objects with tableName set to the table name of data read
- Type
- Promise.<Array.<object>>
(inner) selectCount(options) → {Promise.<int>}
Counts row from a table
Parameters:
Name | Type | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
- Source:
Returns:
- Type
- Promise.<int>
(inner) selectIntoTable() → {Promise}
Merge rows taken from DB to an existent table. If existent rows with same primary key are found, they are
overwritten.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options.table |
DataTable | |||
options.columns |
string | * |
<optional> |
column names comma separated | |
options.orderBy |
string |
<optional> |
||
options.filter |
sqlFun |
<optional> |
||
options.top |
string |
<optional> |
||
options.environment |
Environment |
<optional> |
environment for the current user | |
options.applySecurity |
boolean |
<optional> |
true | if true, security condition is appended to filter |
- Source:
Returns:
- Type
- Promise
(inner) selectRows(opt, rawopt) → {Promise.<Array.<object>>}
Reads data from a table and returns any row read one by one.
Data is returned in a sequence of notification. At the beginning there will be the meta, then each row.
So the first result will be {meta:[array of column descriptors]} then will follow other results like
if raw is false : {row:{object read from db}}
if raw is true : {row:[array of column values]}
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
object |
Properties
|
||||||||||||||||||||||||||||||||||||||||||
raw |
boolean |
<optional> |
false | if raw=true, data returned is not objectified |
- Source:
Returns:
- Type
- Promise.<Array.<object>>
Type Definitions
Deferred
- Source: