riaktor
v0.0.9
Published
a minimalist node.js wrapper for riak built with superagent
Downloads
8
Maintainers
Readme
Riaktor
a functional style riak wrapper for node
Initialize
var db = require('riaktor');
var url = db.construct_url('localhost', '8098');
db.about_my_config(url);
=> I'm riaktor and I am running on http://localhost:8098
Check Health
db.ping(url, function(res) {
console.log(res);
});
=> { request_url: 'localhost:8098/ping', data: 'OK' }
Bucket Operations
db.get_buckets(url, function(res) {
console.log(res);
});
=> {
request_url: 'localhost:8098/riak?buckets=true',
data: [ 'wizard', 'people' ]
}
db.get_keys_in_bucket(url, 'people', function(res) {
console.log(res);
});
=> {
request_url: 'localhost:8098/buckets/people/keys?keys=true',
data: [ 'rculliton', 'john_maynard_keynes' ]
}
Key Operations
db.get_value_from_key(url, 'people', 'rculliton', function(res) {
console.log(res);
});
=> {
request_url: 'localhost:8098/riak/people/rculliton',
id: 'rculliton',
data: { email: '[email protected]' }
}
var data = {email: '[email protected]'};
db.post_value_to_key(url, 'people', 'cbelle', data, function(res) {
console.log(res);
});
=> {
request_url: 'localhost:8098/riak/people/cbelle/?returnbody=true',
id: 'cbelle',
data: { email: '[email protected]' }
}
db.post_value_without_key(url, 'emails', data, function(res) {
console.log(res);
});
=> {
request_url: 'localhost:8098/riak/emails/?returnbody=true',
id: '4azFyFHu0toaQcc2QRIUTRRqNUy',
data: { email: '[email protected]' }
}
var new_data = {email: '[email protected]'};
db.update_value_in_key(url, 'people', 'cbelle', new_data, function(res) {
console.log(res);
});
=> {
request_url: 'localhost:8098/riak/people/cbelle/?returnbody=true',
id: 'cbelle',
data: { email: '[email protected]' }
}
db.delete_value_in_key(url, 'people', 'cbelle', function(res) {
console.log(res);
});
=> {
request_url: 'localhost:8098/riak/people/cbelle',
value_deleted: true
}