Starting with version 4.9, the Apache Software Foundation owns and maintains the NodeJS driver. For the latest version, visit github.com/apache/cassandra-nodejs-driver
Represents a database client that maintains multiple connections to the cluster nodes, providing methods to
execute CQL statements.
The Client uses policies to decide which nodes to connect to, which node
to use per each query execution, when it should retry failed or timed-out executions and how reconnection to down
nodes should be made.
Executes the query and calls rowCallback for each row as soon as they are received. Calls the final
callback after all rows have been sent, or when there is an error.
The query can be prepared (recommended) or not depending on the prepare flag.
Executes callback(err, result) after all rows have been received.
When dealing with paged results, ResultSet#nextPage() method can be used
to retrieve the following page. In that case, rowCallback() will be again called for each row and
the final callback will be invoked when all rows in the following page has been retrieved.
It returns a Promise when a callback is not provided.
Examples:
Promise-based API, using async/await
constquery='SELECT name, email FROM users WHERE id = ?';constresult=awaitclient.execute(query,[id],{prepare:true});constrow=result.first();console.log('%s: %s',row['name'],row['email']);
Callback-based API
constquery='SELECT name, email FROM users WHERE id = ?';client.execute(query,[id],{prepare:true},function(err,result){assert.ifError(err);constrow=result.first();console.log('%s: %s',row['name'],row['email']);});
It returns a Promise when a callback is not provided.
Examples:
Promise-based API, using async/await
constresult=awaitclient.executeGraph('g.V()');// Get the first item (vertex, edge, scalar value, ...)constvertex=result.first();console.log(vertex.label);
Gets a snapshot containing information on the connections pools held by this Client at the current time.
The information provided in the returned object only represents the state at the moment this method was called and
it’s not maintained in sync with the driver metadata.
Executes the query and pushes the rows to the result stream as soon as they received.
The stream is a ReadableStream object
that emits rows.
It can be piped downstream and provides automatic pause/resume logic (it buffers when not read).
The query can be prepared (recommended) or not depending on QueryOptions.prepare flag. Retries on multiple
hosts if needed.