Closed richtera closed 11 years ago
There is. The underlying ._bucket
namespace on the client backend provides this functionality.
HTTPBackend.prototype._bucket.list = function(_return) {
var _this = this._this;
var query = {
path: _this.defaults.resources.riak_kv_wm_index,
options: { buckets: true },
headers: { "accept": "application/json" }
};
_this.GET(query, function(err, obj) {
if(err) _return(err, obj);
else _return(err, obj.data.buckets || []);
});
};
You would get at this like...
var riak = require('nodiak');
riak._bucket.list(function(err, results) {
console.log(results);
});
That said, I would advise not architecting any solution around this functionality for a production application. Listing buckets in Riak is the same operation as listing keys across the cluster, which is a no-no. It's slow and puts a lot of load on the cluster.
Thank you. Yes this would not be normal functionality. This would be to implement a "flush" method to make a riak db look similar to a mongodb. When flush is called under mongo it called dropDatabase. My thought was to iterate through all buckets, find the ones with a common prefix (this is how I was thinking of implementing a "database") and then clear all those buckets. I'll give it a try. Thanks Andy
On Feb 26, 2013, at 8:36 AM, Nathan Aschbacher notifications@github.com wrote:
There is. The underlying ._bucket namespace on the client backend provides this functionality.
HTTPBackend.prototype._bucket.list = function(_return) { var _this = this._this;
var query = { path: _this.defaults.resources.riak_kv_wm_index, options: { buckets: true }, headers: { "accept": "application/json" } }; _this.GET(query, function(err, obj) { if(err) _return(err, obj); else _return(err, obj.data.buckets || []); });
}; You would get at this like...
var riak = require('nodiak');
riak._bucket.list(function(err, results) { console.log(results); }); That said, I would advise not architecting any solution around this functionality for a production application. Listing buckets in Riak is the same operation as listing keys across the cluster, which is a no-no. It's slow and puts a lot of load on the cluster.
— Reply to this email directly or view it on GitHub.
Sure thing. Feel free to reopen if you have any more questions.
I would like to implement a way to iterate through all buckets or buckets matching some kind of expression to be able to clear several of them.