Mixin: Binding

Binding

This mixin grants placeholder assignment capabilities to a statement instance via composition.

Methods


bind(nameOrMultipleAssignments [, value])

Assign a single value to a given placeholder or multiple values to different placeholders when the input is an object where the keys correspond to placeholder names and the values correspond to the values that are assigned to those placeholders.
Parameters:
Name Type Argument Description
nameOrMultipleAssignments string | Object A placeholder name or an object containing placeholder names and values.
value string <optional>
A value to be assigned to a single placeholder,
Returns:
The instance of the statement itself following a fluent API convention.
Type
Binding
Example
// parameter name and value as arguments
const query = collection.find('foo = :foo').bind('foo', 'bar')

// parameter name and value as key-value pair in an object
const query = collection.find('foo = :foo').bind({ foo: 'bar' })