new SQLClient()
A common asynchronous client interface for interacting with SQL compliant database
- Source:
Methods
call(sql, handler) → {SQLClient}
Calls the given SQL
PROCEDURE which returns the result from the procedure.
Parameters:
| Name | Type | Description |
|---|---|---|
sql |
string | the SQL to execute. For example {call getEmpName}. |
handler |
function | the handler which is called once the operation completes. It will return a ResultSet. |
- Source:
Returns:
- Type
- SQLClient
callWithParams(sql, params, outputs, handler) → {SQLClient}
Calls the given SQL
PROCEDURE which returns the result from the procedure.
The index of params and outputs are important for both arrays, for example when dealing with a prodecure that
takes the first 2 arguments as input values and the 3 arg as an output then the arrays should be like:
params = [VALUE1, VALUE2, null]
outputs = [null, null, "VARCHAR"]
Parameters:
| Name | Type | Description |
|---|---|---|
sql |
string | the SQL to execute. For example {call getEmpName (?, ?)}. |
params |
todo | these are the parameters to fill the statement. |
outputs |
todo | these are the outputs to fill the statement. |
handler |
function | the handler which is called once the operation completes. It will return a ResultSet. |
- Source:
Returns:
- Type
- SQLClient
close(handler)
Close the client and release all resources.
Call the handler when close is complete.
Parameters:
| Name | Type | Description |
|---|---|---|
handler |
function | the handler that will be called when close is complete |
- Source:
getConnection(handler) → {SQLClient}
Returns a connection that can be used to perform SQL operations on. It's important to remember
to close the connection when you are done, so it is returned to the pool.
Parameters:
| Name | Type | Description |
|---|---|---|
handler |
function | the handler which is called when the JdbcConnection object is ready for use. |
- Source:
Returns:
- Type
- SQLClient
query(sql, handler) → {SQLClient}
Execute a single SQL statement, this method acquires a connection from the the pool and executes the SQL
statement and returns it back after the execution.
Parameters:
| Name | Type | Description |
|---|---|---|
sql |
string | the statement to execute |
handler |
function | the result handler |
- Source:
Returns:
self
- Type
- SQLClient
querySingle(sql, handler) → {SQLOperations}
Execute a one shot SQL statement that returns a single SQL row. This method will reduce the boilerplate code by
getting a connection from the pool (this object) and return it back after the execution. Only the first result
from the result set is returned.
Parameters:
| Name | Type | Description |
|---|---|---|
sql |
string | the statement to execute |
handler |
function | the result handler |
- Source:
Returns:
self
- Type
- SQLOperations
querySingleWithParams(sql, arguments, handler) → {SQLOperations}
Execute a one shot SQL statement with arguments that returns a single SQL row. This method will reduce the
boilerplate code by getting a connection from the pool (this object) and return it back after the execution.
Only the first result from the result set is returned.
Parameters:
| Name | Type | Description |
|---|---|---|
sql |
string | the statement to execute |
arguments |
todo | the arguments |
handler |
function | the result handler |
- Source:
Returns:
self
- Type
- SQLOperations
queryWithParams(sql, arguments, handler) → {SQLClient}
Execute a single SQL prepared statement, this method acquires a connection from the the pool and executes the SQL
prepared statement and returns it back after the execution.
Parameters:
| Name | Type | Description |
|---|---|---|
sql |
string | the statement to execute |
arguments |
todo | the arguments to the statement |
handler |
function | the result handler |
- Source:
Returns:
self
- Type
- SQLClient
update(sql, handler) → {SQLClient}
Executes the given SQL statement which may be an
INSERT, UPDATE, or DELETE
statement.
Parameters:
| Name | Type | Description |
|---|---|---|
sql |
string | the SQL to execute. For example INSERT INTO table ... |
handler |
function | the handler which is called once the operation completes. |
- Source:
Returns:
- Type
- SQLClient
updateWithParams(sql, params, handler) → {SQLClient}
Executes the given prepared statement which may be an
INSERT, UPDATE, or DELETE
statement with the given parameters
Parameters:
| Name | Type | Description |
|---|---|---|
sql |
string | the SQL to execute. For example INSERT INTO table ... |
params |
todo | these are the parameters to fill the statement. |
handler |
function | the handler which is called once the operation completes. |
- Source:
Returns:
- Type
- SQLClient