Module: SqlExecute

SqlExecute factory.
Mixes In:

Members


<static, constant> Namespace :Type

MySQL protocol namespace.
Type:
  • Type

Methods


bind(values)

Bind values to ordinal query placeholders.
Parameters:
Name Type Description
values string | Array.<string> one or more values to bind
Returns:
The query instance.
Type
module:SqlExecute
Example
// values as arguments
const query = session.sql('SELECT FROM person WHERE name = ? AND age = ?').bind('foo', 23)

// values as a single array argument
const query = session.sql('SELECT FROM person WHERE name = ? AND age = ?').bind(['foo', 23])

execute(rowcb [, metacb])

Execute a raw SQL query.
Parameters:
Name Type Argument Description
rowcb module:SqlExecute~rowCursor Callback function to handle results, or an object with both callback functions.
metacb module:SqlExecute~metadataCursor <optional>
Callback function to handle metadata.
Returns:
Type
Promise.<module:SqlResult>
Example
// provide only a callback to handle results
query.execute(result => {})
query.execute({ result () {} })

// provide only a callback to handle metadata
query.execute({ meta () {} })

// provide callbacks to handle results and metadata
query.execute(result => {}, meta => {})
query.execute({ result () {}, meta () {} })

Type Definitions


metadataCursor(metadata)

Metadata cursor.
Parameters:
Name Type Description
metadata Array.<Object> the list of objects containing metadata details for each column

rowCursor(items)

Row cursor.
Parameters:
Name Type Description
items Array.<*> the list of column values for the row in the current cursor position