mirror of
https://github.com/donl/slouch.git
synced 2026-06-30 06:11:57 -06:00
Added db.isPartitioned(dbName) and extended db.create(dbName, params) to allow creation of partitioned database (#128)
This commit is contained in:
parent
8fb3c67085
commit
97ec00e958
3 changed files with 36 additions and 6 deletions
|
|
@ -7,17 +7,18 @@ var DB = function (slouch) {
|
|||
this._slouch = slouch;
|
||||
};
|
||||
|
||||
DB.prototype._create = function (dbName) {
|
||||
DB.prototype._create = function (dbName, params) {
|
||||
return this._slouch._req({
|
||||
uri: this._slouch._url + '/' + encodeURIComponent(dbName),
|
||||
method: 'PUT'
|
||||
method: 'PUT',
|
||||
qs: params
|
||||
});
|
||||
};
|
||||
|
||||
DB.prototype.create = function (dbName) {
|
||||
DB.prototype.create = function (dbName, params) {
|
||||
var self = this;
|
||||
|
||||
return self._create(dbName).catch(function (err) {
|
||||
return self._create(dbName, params).catch(function (err) {
|
||||
// During heavy traffic, CouchDB does this strange thing where it will return an error even when
|
||||
// the DB has been created. So, we check to see if the DB exists and then only throw the error
|
||||
// if the DB does not exist.
|
||||
|
|
@ -29,6 +30,12 @@ DB.prototype.create = function (dbName) {
|
|||
});
|
||||
};
|
||||
|
||||
DB.prototype.isPartitioned = function (dbName) {
|
||||
return this.get(dbName).then(function (obj) {
|
||||
return obj.props && (obj.props.partitioned === true);
|
||||
});
|
||||
};
|
||||
|
||||
DB.prototype.destroy = function (dbName) {
|
||||
return this._slouch._req({
|
||||
uri: this._slouch._url + '/' + encodeURIComponent(dbName),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue