Skip to content

Instantly share code, notes, and snippets.

@batasrki
Created November 7, 2011 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save batasrki/1345669 to your computer and use it in GitHub Desktop.
Save batasrki/1345669 to your computer and use it in GitHub Desktop.
Map/Reduce inside a Ripple document
def record_ids_containing_category(category)
function = <<-eos
function(values) {
var data = Riak.mapValuesJson(values)[0];
if(data.category === '#{category}') {
return [values.key];
}
else {
return [];
}
}
eos
Riak::MapReduce.new(bucket.client).add("transactions").map(function, :keep => true).run
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment