Skip to content

fohr/node-cql3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Note: This module is still in development and is not completely usable yet. If you are interested in helping, please send me a message.

Description

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.

API

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'

Client

(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 query
  • consistency can be one of these options: * 0 - ANY * 1 - ONE * 2 - TWO * 3 - THREE * 4 - QUORUM * 5 - ALL * 6 - LOCAL_QUORUM * 7 - EACH_QUORUM
  • callback (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 query
  • callback (err, result)

execute( <integer> id, [ <Array> values], [ <integer> consistency], <function> callback )

  • id the query id returned from a prepare() call
  • values an array of values for the query
  • consistency is the same as in query()

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

Todo

  • Snappy compression
  • Tracing

About

CQL3 binary protocol driver

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published