Skip to content

Instantly share code, notes, and snippets.

@alejamp
Forked from frank06/failing_mr.js
Created October 25, 2011 06:58
Show Gist options
  • Save alejamp/1311649 to your computer and use it in GitHub Desktop.
Save alejamp/1311649 to your computer and use it in GitHub Desktop.
db = require('riak-js').getClient()
db
.add([['catalogs', 'politics']])
.link({ bucket: 'books', keep: false })
.map(function(value) {
// ejsLog('/tmp/mapreduce', JSON.stringify(value));
value = Riak.mapValuesJson(value)[0];
return [
{
id: value.id,
title: value.title,
author: value.author
}
];
})
.reduce(function(values) {
return values.sort(function(a, b) { return a.title < b.title ? -1 : 1; });
})
.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment