Statement <T>
A statement generated by Database.prepare used to prepare SQL with ? bindings
Type parameters
Name |
---|
T |
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new Statement<T
>(database
, sql
, ...params
): Statement
<T
>
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
database | Database |
sql | string |
...params | any [] |
Returns
Statement
<T
>
Defined in
Properties
_database
• Private
_database: Database
Statement belongs to this database
Defined in
_preparedSql
• Private
Optional
_preparedSql: string
The SQL statement with binding values applied
Defined in
_sql
• Private
_sql: string
The SQL statement with ? binding placeholders
Defined in
Methods
all
â–¸ all(callback?
): Statement
<T
>
Binds parameters, executes the statement and calls the callback with all result rows. The function returns the Statement object to allow for function chaining. The parameters are the same as the Statement#run function
Parameters
Name | Type |
---|---|
callback? | RowsCallback <T > |
Returns
Statement
<T
>
Defined in
â–¸ all(params
, callback?
): Statement
<T
>
Parameters
Name | Type |
---|---|
params | any |
callback? | RowsCallback <T > |
Returns
Statement
<T
>
Defined in
bind
â–¸ bind(...params
): Statement
<T
>
Binds parameters to the prepared statement and calls the callback when done or when an error occurs. The function returns the Statement object to allow for function chaining. The first and only argument to the callback is null when binding was successful, otherwise it is the error object. Binding parameters with this function completely resets the statement object and row cursor and removes all previously bound parameters, if any. Currently bound parameters are escaped client side and turned into literals before being executed on the server.
Parameters
Name | Type |
---|---|
...params | any [] |
Returns
Statement
<T
>
Defined in
each
â–¸ each(callback?
, complete?
): Statement
<T
>
Binds parameters, executes the statement and calls the callback for each result row. The function returns the Statement object to allow for function chaining. Parameters are the same as the Database#each function.
Parameters
Name | Type |
---|---|
callback? | RowCallback <T > |
complete? | RowCountCallback |
Returns
Statement
<T
>
Defined in
â–¸ each(params
, callback?
, complete?
): Statement
<T
>
Parameters
Name | Type |
---|---|
params | any |
callback? | RowCallback <T > |
complete? | RowCountCallback |
Returns
Statement
<T
>
Defined in
get
â–¸ get(callback?
): Statement
<T
>
Binds parameters, executes the statement and retrieves the first result row. The function returns the Statement object to allow for function chaining. The parameters are the same as the Statement#run function, with the following differences: The signature of the callback is function(err, row) {}. If the result set is empty, the second parameter is undefined, otherwise it is an object containing the values for the first row.
Parameters
Name | Type |
---|---|
callback? | RowCallback <T > |
Returns
Statement
<T
>
Defined in
â–¸ get(params
, callback?
): Statement
<T
>
Parameters
Name | Type |
---|---|
params | any |
callback? | RowCallback <T > |
Returns
Statement
<T
>
Defined in
run
â–¸ run(callback?
): Statement
<T
>
Binds parameters and executes the statement. The function returns the Statement object to allow for function chaining. If you specify bind parameters, they will be bound to the statement before it is executed. Note that the bindings and the row cursor are reset when you specify even a single bind parameter. The callback behavior is identical to the Database#run method with the difference that the statement will not be finalized after it is run. This means you can run it multiple times.
Parameters
Name | Type |
---|---|
callback? | ResultsCallback <T > |
Returns
Statement
<T
>
Defined in
â–¸ run(params
, callback?
): Statement
<T
>
Parameters
Name | Type |
---|---|
params | any |
callback? | ResultsCallback <T > |
Returns
Statement
<T
>