Skip to content

Instantly share code, notes, and snippets.

@calvinfo
Created October 12, 2012 22:41
Show Gist options
  • Save calvinfo/3882058 to your computer and use it in GitHub Desktop.
Save calvinfo/3882058 to your computer and use it in GitHub Desktop.
CF key_range_slice demo
var helenus = require('helenus');
pool = new helenus.ConnectionPool({
hosts : ['localhost:9160'],
keyspace : 'segmentio',
timeout : 3000
});
pool.on('error', function(err){
console.error(err.name, err.message);
});
pool.connect(function(err, keyspace){
if(err)
throw err;
keyspace.get('Projects', function (err, cf) {
if (err)
throw err;
var numProjects = 0;
var stream = cf.getRange(); // accepts { start : startKey, end : endKey }
stream.on('data', function (data) { numProjects += 1; });
stream.on('end', function () { console.log('Found', numProjects, 'project'); });
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment