new DataAccess(options)
A DataAccess is a rich connection to a database and provides many non-blocking query functions to manage it.
Normally a connection is leaved open since it is destroyed. Setting persisting to false changes this
default behaviour
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
- Source:
Members
externalUser
Properties:
Name | Type | Description |
---|---|---|
externalUser |
string |
- Source:
persisting
Set persisting to false if you want to manage manually the opening and closing of the connection
Default is true, so that the underlying connection is open at the creation of the connection and closed
when the object is destroyed
Properties:
Name | Type | Description |
---|---|---|
persisting |
boolean |
- Source:
security
Security function provider for this connection
Properties:
Name | Type | Description |
---|---|---|
security |
Security |
- Source:
sqlConn
underlying DB connection
Properties:
Name | Type | Description |
---|---|---|
sqlConn |
SqlDriver |
- Source:
Methods
beginTransaction(isolationLevel) → {Promise}
Begins a transaction
Parameters:
Name | Type | Description |
---|---|---|
isolationLevel |
string | 'READ UNCOMMITTED','READ COMMITTED','REPEATABLE READ','SNAPSHOT','SERIALIZABLE' |
- Source:
Returns:
- Type
- Promise
callSPWithNamedParams(spName, paramList, rawopt) → {Promise.<Array>}
call SP with a list of parameters each of which is an object of type sqlParameter having:
value : the value to be passed to the parameter, if it is not an output parameter
{bool} [out=false]: true if it is an output parameter
{string} [sqltype] : a type name compatible with the underlying db, necessary if is an output parameter
{string} [name] necessary if it is an output parameter
If any output parameter is given, the corresponding outValue will be filled after the SP has run
After returning all tables given by the stored procedure, this method eventually returns an object with a property for each output parameter
value : the value to be passed to the parameter, if it is not an output parameter
{bool} [out=false]: true if it is an output parameter
{string} [sqltype] : a type name compatible with the underlying db, necessary if is an output parameter
{string} [name] necessary if it is an output parameter
If any output parameter is given, the corresponding outValue will be filled after the SP has run
After returning all tables given by the stored procedure, this method eventually returns an object with a property for each output parameter
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
spName |
string | |||
paramList |
Array.<sqlParameter> | |||
raw |
<optional> |
false | when true data will be returned as array(s) of simple values, without calling objectify on it |
- Source:
Returns:
(a sequence of arrays)
- Type
- Promise.<Array>
Example
var arr = [{name:'idcustomer', value:1}, {name:maxValue, sqlType:int, value:null, out:true}];<br>
DA.callSPWithNamedParams('getMaxOrder',arr);<br>
At the end arr will be modified and a outValue added:<br>
[{name:'idcustomer', value:1}, {name:maxValue, sqlType:int, value:null, out:true, outValue:12}]