Repository URL to install this package:
|
Version:
3.2.0 ▾
|
| .. |
| README.md |
You can bind the values of parameters in a prepared statement either by position or by using named markers.
When using positional parameters, the query parameters must be provided as an Array.
const query = 'INSERT INTO artists (id, name) VALUES (?, ?)'; // Parameters by marker position const params = ['krichards', 'Keith Richards']; client.execute(query, params, { prepare: true });
You declare the named markers in your queries and use a JavaScript object properties to define the parameters, with
the Object property names matching the parameters names.
const query = 'INSERT INTO artists (id, name) VALUES (:id, :name)'; // Parameters by marker name const params = { id: 'krichards', name: 'Keith Richards' }; client.execute(query, params, { prepare: true });
Defining named markers in your queries is supported in Cassandra 2.0 or greater for prepared statements and Cassandra 2.1 or greater for non-prepared statements.