Skip to content

Instantly share code, notes, and snippets.

@nlf
Created June 30, 2014 18:51
Show Gist options
  • Save nlf/c4518420b1dc21960791 to your computer and use it in GitHub Desktop.
Save nlf/c4518420b1dc21960791 to your computer and use it in GitHub Desktop.
var levelup = require('levelup');
var riakdown = require('riakdown');
var concat = require('concat-stream');
var db = levelup('riak://localhost:8087/default', {db: riakdown, valueEncoding: 'json'});
db.put('testkey', '{"name": "ham"}', {indexes: [{key: 'name_bin', value: 'ham'}], bucket: 'default'}, function (err, extra) {
db.createReadStream({
index: 'name_bin',
start: 'ham',
end: 'ham',
bucket: 'default'
}).pipe(concat(function (results) {
console.log("results 1");
console.log(results);
db.put('testkey', '{"name": "salami"}', {indexes: [{key: 'name_bin', value: 'salami'}], bucket: 'default', vclock: extra.vclock}, function (err) {
db.createReadStream({
index: 'name_bin',
start: 'ham',
end: 'ham',
bucket: 'default'
}).pipe(concat(function (results) {
console.log("results 2");
console.log(results);
}));
});
}));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment