Created
October 22, 2013 08:04
-
-
Save sideshowcoder/7096848 to your computer and use it in GitHub Desktop.
getAll (JSON) Values from a bucket, via riak-js or curl
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 db = require("riak-js").getClient() | |
var async = require("async") | |
var kvPairs = [ | |
{ key: "foo0", value: { somthing: "else0" } }, | |
{ key: "foo1", value: { somthing: "else1" } }, | |
{ key: "foo2", value: { somthing: "else2" } }, | |
{ key: "foo3", value: { somthing: "else3" } }, | |
{ key: "foo4", value: { somthing: "else4" } }, | |
{ key: "foo5", value: { somthing: "else5" } }, | |
{ key: "foo6", value: { somthing: "else6" } }, | |
{ key: "foo7", value: { somthing: "else7" } }, | |
{ key: "foo8", value: { somthing: "else8" } }, | |
] | |
async.each( | |
kvPairs, | |
function(p, cb) { | |
db.save("test_data", p.key, p.value, cb) | |
}, | |
function(err) { | |
db.getAll("test_data", function(err, objects, meta) { | |
if(err) throw err | |
console.log(objects) | |
console.log(meta) | |
}) | |
} | |
) | |
/** | |
* Getting the data via curl: | |
* curl -XPOST http://localhost:8098/mapred \ | |
* -H 'Content-Type: application/json' \ | |
* -d '{"inputs": "test_data", "query":[{"map": {"language": "javascript","source": "Riak.mapValuesJson"}}] }' | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment