query.createBinding

Stores the passed data into the data bindings collection and returns a
unique string representation of that data for use in the query.

Data bindings in queryize are represented by a key name surrounded by
double brackets. These values are then converted to question marks after
the query is compiled, with the values appended to the data array.

If a modifier function name is provided, the returned binding will be wrapped with that MySQL function.

query.addRow

Adds a row of data for a multi-row insert. Activates Multi-Insert Mode for the query.

About Multi-Insert Mode:

Single row inserts are performed using INSERT SET queries, where each column value is defined one at a time.
Example: INSERT INTO user SET firstname=?, lastname=?

This is more efficient for query generation and less prone to mistakes, but can only insert a single row at a time. When in Multi-Insert Mode, Queryize will construct an INSERT VALUES query where all columns are defined up front and preceded by multiple data sets.

Example: INSERT INTO user (firstname, lastname) VALUES (?,?), (?,?)

This format is more performant for inserting multiple uniform data sets, but is less flexible as all the columns must be known upfront. If row contents are provided as arrays, the column order must be defined before calling query.addRow. If keyed objects are provided then Queryize will use the keys to identify the column names to use.

Any rows with missing columns will receive NULL for the column's contents.

Usage:

query.addRow(data)

data Array, Object

May be an object where the keys represent all columns, or an array that matches the number of columns already defined.

query._convertNamedParameters

Processes the freshly compiled query string, replacing all data bindings with placeholders and constructs the data array
If useBoundParameters is turned off, it replaces the placeholders with their escaped values.

query.exec

Compiles the MySQL query and runs it using the provided connection or connection pool from node-mysql or node-mysql2.
If the connection provided is a node-mysql2 connection, then the query will be executed as a prepared statement (connection.execute).

Usage:

query.exec(connection, [options], [callback])

connection Object

node-mysql(2) connection(Pool)

options Object
Optional

Options object to be passed to connection.query with the query string and data mixed in.

INTERNAL: Query builders can now return a fully formed query object instead of a string.

0.6.0 / 2014-09-12

Added query.emitted() as an alternative to query.exec().

node-mysql does not return a row emitter if a callback is provided. Since a callback is always provided as
part of the promise extension, this made it impossible to receive a row emitter when using node-mysql
(node-mysql2 does not have this limitation). This new function works around that limitation.

0.5.1 / 2014-09-13

Removed a console.log that slipped in.

0.5.0 / 2014-09-12

Added ability to provide a queryize object as a compound where condition.

0.4.0 / 2014-09-03

Added support for using queryize objects as subqueries in columns, joins and select from.

Use query.as(name) to define the name for the subquery. If omitted, queryize will create a random name.

Fixed bug in query.debug() that prevented it from enabling without passing true.

Added documentation examples for all possible ways you can use query.exec()

0.3.0 / 2014-09-02

Major internal refactor to make the query object more externally extensible

Query state is now stored on this._attributes instead of in a local variable.

queryize.fn now contains the prototype of the queryize query object. See lib/mutators.js for the contents.

Added query.clone() to duplicate a query state inline

Changed query.deleet() to query.delete()

Switched to using lodash clone and assign functions instead of local versions.