Note: This module is still in development and is not completely usable yet. If you are interested in helping, please send me a message.
A driver for Cassandra's CQ3 binary protocol. It doesn't provide high-level client functionality like abstracted queries, multiple server connections, etc. That functionality can be built on top of this module easily, however.
var Client = require('cql3').Client;
var client = new Client('localhost', 9130);
client.connect(function(err) {
if(!err) {
init();
}
});
function init() {
client.query('USE test;', function(err, result) {
if(!err) {
console.log(result);
}
});
}
---------------------
'test'
(constructor)( <string> host, <integer> port, <object> options )
connect( <function> callback )
callback
(err)
query( <string> query, <int> consistency, <function> callback ) - send a CQL3 query to the server callback has the form (err, result) where the format of result depends on the query (see below).
query
a CQL3 queryconsistency
can be one of these options: * 0 - ANY * 1 - ONE * 2 - TWO * 3 - THREE * 4 - QUORUM * 5 - ALL * 6 - LOCAL_QUORUM * 7 - EACH_QUORUMcallback
(err, result) result type will vary depending on the query (see below)
prepare( <string> query, <function> callback ) - prepare a query for later execution with execute()
query
a CQL3 querycallback
(err, result)
execute( <integer> id, [ <Array> values], [ <integer> consistency], <function> callback )
id
the query id returned from a prepare() callvalues
an array of values for the queryconsistency
is the same as inquery()
register( <Array> events, <function> callback) - register to recieve push events from Cassandra
events
an array of string events to listen for. Events recieved from Cassandra will be emitted from the Client.callback
(err)
disconnect() - close the connection with Cassandra
- Snappy compression
- Tracing