Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix admin

  • Loading branch information...
commit 7bcd57d1db9dcc38f601dd09fe589f584259b71e 1 parent c8a1fa7
@guileen authored
Showing with 20 additions and 3 deletions.
  1. +9 −0 examples/admin.js
  2. +11 −3 lib/mongoskin/admin.js
View
9 examples/admin.js
@@ -0,0 +1,9 @@
+var db = require('./config').db;
+
+db.admin.listDatabases(function(err, result){
+ if(err) {
+ console.traceError(err);
+ }
+ console.log(result);
+ db.close();
+})
View
14 lib/mongoskin/admin.js
@@ -3,17 +3,25 @@ var Admin = require('mongodb').Admin
var SkinAdmin = exports.SkinAdmin = function(skinDb) {
this.skinDb = skinDb;
- this.nativeAdmin = new Admin(this.skinDb.nativeDb);
+}
+
+SkinAdmin.prototype.open = function(callback) {
+ if(this.admin) return callback(null, this.admin);
+ this.skinDb.open(function(err, db){
+ if(err) return callback(err);
+ this.admin = new Admin(db);
+ callback(null, this.admin);
+ })
}
var bindSkin = function(name, method) {
SkinAdmin.prototype[name] = function() {
var args = arguments.length > 0 ? Array.prototype.slice.call(arguments, 0) : [];
- return this.skinDb.open(function(err, db) {
+ return this.open(function(err, admin) {
if (err) {
utils.error(err, args, 'SkinAdmin.' + name);
} else {
- method.apply(this.nativeAdmin, args);
+ method.apply(admin, args);
}
});
};
Please sign in to comment.
Something went wrong with that request. Please try again.