Module: SqlExecute

SqlExecute factory.
Mixes In:
Source:

Members

(static, constant) Namespace :Type

MySQL protocol namespace.
Type:
  • Type
Source:

Methods

bind(values) → {module:SqlExecute}

Bind values to ordinal query placeholders.
Parameters:
Name Type Description
values string | Array.<string> one or more values to bind
Source:
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, metacbopt) → {Promise}

Execute a raw SQL query.
Parameters:
Name Type Attributes 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.
Source:
Returns:
Type
Promise
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
Source:

rowCursor(items)

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