Skip to content

Instantly share code, notes, and snippets.

@ndrut
Last active December 10, 2015 23:28
Show Gist options
  • Select an option

  • Save ndrut/4509161 to your computer and use it in GitHub Desktop.

Select an option

Save ndrut/4509161 to your computer and use it in GitHub Desktop.
Return all keys residing in a Riak bucket from nodejs using Express.
app.get('/list/:bucket', function (req,res){
var keys = [];
res.setHeader('Content-Type', 'application/json');
db.keys(req.params.bucket, {keys: 'stream', props: false})
.on('keys',
function(data) {
console.log(data);
data.forEach(function(key) {
keys.push(key);
});
}
)
.on('end', function() {
res.send(keys);
})
.start();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment