The Riak way to enlightenment
$ npm install zen.js
####zen.use([url, options])
Sets Riak's url and optionally specifies protocol (http or protobuf)
zen.use() // default to http://localhost:8098
zen.use('http://site.com:1234')
zen.use({protocol: 'http'})
zen.use('http://site.com:1234', {protocol: 'protobuf'})
Gets a list of buckets from the database
WARNING: This function should not be used in production environment because it consumes a lot of memory
zen.listBuckets(function(e, buckets) {
console.log(buckets) // []
});
Gets properties for the specified bucket
zen.getBucket('bucket', function(e, bucket) {
console.log(bucket.props) // {name: 'bucket'.... }
});
zen.getBucket('bucket', {'Content-Type': 'application/json'}, function(err, bucket) {
console.log(bucket.props) // {name: 'bucket'.... }
});
Sets properties for the specified bucket
zen.setBucket('bucket', {'last_write_wins': true}, function(e) {
console.log(e) // null
});
zen.setBucket(
'bucket'
, {'last_write_wins': true}
, {'Content-Type': 'application/json'}
, function(e) {
console.log(e) // null
});
Stores an object in the database
zen.store('bucket', 'key', {hey: 'hi'}, function(e) {
console.log(e) // null
});
zen.store('bucket', {hey: 'hi'}, function(e) {
console.log(e) // null
});
zen.store('bucket', 'key', {hey: 'hi'}, {
'Content-Type': 'text/plain'
},function(e) {
console.log(e) // null
});
Fetches an object from the database
zen.fetch('bucket', 'key', {header: 'val'}, function(e, i) {
console.log(i) // {key: 'val'}
});
Deletes an object from the database
zen.delete('bucket', 'key', {header: 'val'}, function(e) {
console.log(e); // null
});
Checks if database is online
zen.ping(function(e, online) {
console.log(online) // true
});
Returns Riak's performance and configuration datas
WARNING: it requires riak_kv_stat
to be enabled
zen.status(function(e, stats) {
console.log(stats) // {....}
});
Performs a mapReduce operation
More info here
zen.mapReduce([['bucket1', 'key1'], ['bucket2', 'key2']], function(v) { ... }, function(v) { ... }, function(e, i) {
console.log(i); // [...]
});
Tests are written with Mocha
$ npm test
MIT (see LICENSE
)
- Protobuf APIs