Skip to content
Permalink
Browse files

[refactor] Refactor for latest version of databases API

  • Loading branch information...
indexzero committed Jul 13, 2012
1 parent be0b57f commit 58dc131a8ec71e611d7201e3eef2a1d306bb2735
Showing with 33 additions and 12 deletions.
  1. +33 −12 node.js/lib/client/databases.js
@@ -29,9 +29,15 @@ util.inherits(Databases, Client);
// Provisions a database for the user
//
Databases.prototype.create = function (databaseType, databaseName, callback) {
this.request('POST', ['databases', this.options.get('username'), databaseName], {type:databaseType}, callback, function (res, result) {
callback(null, result, res);
});
this.request(
'POST',
['databases', this.options.get('username'), databaseName],
{ type: databaseType },
callback,
function (res, result) {
callback(null, result.database, res);
}
);
};

//
@@ -41,9 +47,14 @@ Databases.prototype.create = function (databaseType, databaseName, callback) {
// Gets the metadata for the specified database
//
Databases.prototype.get = function (databaseName, callback) {
this.request('GET', ['databases', this.options.get('username'), databaseName], callback, function (res, result) {
callback(null, result);
});
this.request(
'GET',
['databases', this.options.get('username'), databaseName],
callback,
function (res, result) {
callback(null, result.database);
}
);
};

//
@@ -52,9 +63,14 @@ Databases.prototype.get = function (databaseName, callback) {
// Gets the list of databases assigned to the user
//
Databases.prototype.list = function (callback) {
this.request('GET', ['databases', this.options.get('username')], callback, function (res, result) {
callback(null, result);
});
this.request(
'GET',
['databases', this.options.get('username')],
callback,
function (res, result) {
callback(null, result.databases);
}
);
};

//
@@ -64,7 +80,12 @@ Databases.prototype.list = function (callback) {
// Deprovisions specified database
//
Databases.prototype.destroy = function (databaseName, callback) {
this.request('DELETE', ['databases', this.options.get('username'), databaseName], callback, function (res, result) {
callback(null, result);
});
this.request(
'DELETE',
['databases', this.options.get('username'), databaseName],
callback,
function (res, result) {
callback(null, result);
}
);
}

0 comments on commit 58dc131

Please sign in to comment.
You can’t perform that action at this time.