Skip to content

fed135/scylla-driver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ScyllaDB Node.js Driver

Work in progress - do not use!

ScyllaDB Node Build Status


Disclaimer I am not associated in any way with ScyllaDB or Datastax. Just a guy in need of a good solution to his problems.

Loosely based on the current datastax cassandra driver, it focuses on performance and a cleaner interface.


Install

$ npm install scylladb

Usage

Connecting

Creating a client will spawn multiple forks to allow for more paralel work.

const scylladb = require('scylladb');
const client = scylladb.createClient({
  hosts: ['0.0.0.0', '0.0.0.1'],
  keyspace: 'ks1'
});

Options

Fields Description
hosts List of hosts to connect to. Can be an IP, a fqdn or a unix socket (required)
keyspace The keyspace to select (required)
workers The number of connection workers to spawn per host (default: 10)

Querying

Querying has been streamlined to now only return a Promise or a Stream.

client.execute('SELECT name, email FROM users WHERE key = ?', [ 'someone' ], { prepare: true })
  .then(result => console.log(`User with email ${result.rows[0].email}`));

Row streaming

It can be piped downstream and provides automatic pause/resume logic (it buffers when not read).

client.stream('SELECT time, val FROM temperature WHERE station_id=', [ 'abc' ])
  .on('readable', (rows) {
    rows.forEach(row => console.log(`time ${row.time} and value ${row.value}`));
  })
  .on('end', () => console.log('stream ended')); 
  .on('error', err => console.log(`Error: ${err}`));

Logging

ScyllaDB driver uses debug

DEBUG=scylladb:* 

The level being passed to debug can be verbose, info, warning or error.

Contribute

I am always looking for maintainers. Reach out to me to get involved.

Tests

Requirements

Once you have a database setup with a keyspace named "test" and a table "users".
Help can be found in the wiki.

Usage

Tests can be run with:

npm run test

License

Apache 2.0 (c) 2017 Frederic Charette