- 
                Notifications
    You must be signed in to change notification settings 
- Fork 17
API Statement
        Michael Anderson edited this page Dec 13, 2017 
        ·
        2 revisions
      
    A Statement takes an SQL expression as a string and makes it executable or queryable against a database table.
connection.createStatement( sql : string )
| Parameter | Type | Description | 
|---|---|---|
| sql | string | The SQL expression used to form the statement. | 
Sends a query to the database after escaping and substituting any parameters passed in.
statement.query( ...args: Array<any> ) => Promise<Array<any>>
| Parameter | Type | Description | 
|---|---|---|
| args | Array<any> | A rest parameter array of values to be substituted for the ?tokens in the SQL.The number of parameters must match the number of ?tokens. | 
| Type | Description | 
|---|---|
| Promise<Array<Object>> | An arry of database rows represented as JSON objects. | 
Prepares the statement to receive parameters.
statement.prepare()
| Type | Description | 
|---|---|
| void | 
Executes a statement on the database after escaping and substituting any parameters passed in.
statement.execute( ...args: Array<any> ) => any
| Parameter | Type | Description | 
|---|---|---|
| args | Array<any> | A rest parameter array of values to be substituted for the ?tokens in the SQL.The number of parameters must match the number of ?tokens. | 
| Type | Description | 
|---|---|
| Promise<Any> | If the underlying driver returns anything, it will be returned in a promise. Not all drivers or databases have a return from an execute. |