Created
October 12, 2012 22:41
CF key_range_slice demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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