bind
Function: bind()
bind<
T>(query,params?):WebdaQLString<T>
Defined in: packages/ql/src/bind.ts:69
Bind the ? or :name placeholders of a WebdaQL query to values
bind("status = ? AND owner IN ?", ["open", ["alice", "bob"]]);
// status = 'open' AND owner IN ['alice', 'bob']
bind("owner = :owner AND priority >= :min", { owner: "alice", min: 2 });
// owner = 'alice' AND priority >= 2
Placeholders are found by the WebdaQL lexer, so a ? or :name inside a quoted string is
left alone, and the grammar only accepts them where a value is expected: a placeholder can
never become an attribute, an operator or a keyword. Values are escaped exactly like the
template literals rewritten at compile time (see escape), including = ? with
null or undefined becoming IS NULL and != ? becoming IS NOT NULL.
Type Parameters
T
T = unknown
Parameters
query
string
the query, with ? or :name placeholders
params?
an array of values for ?, an object of values for :name
Returns
the query with every placeholder replaced by its escaped value
Throws
if the query does not follow the grammar, e.g. a placeholder used as an attribute
Throws
if parameters are missing, extra, unused, mixed, or not representable