|
|
@ -104,20 +104,24 @@ Database.prototype.runCommand = function (opts, cb) { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
Database.prototype.getCollectionNames = function (cb) { |
|
|
|
function mapCollectionNames (collection) { |
|
|
|
return collection.name |
|
|
|
} |
|
|
|
|
|
|
|
Database.prototype.listCollections = function (cb) { |
|
|
|
this._getConnection(function (err, connection) { |
|
|
|
if (err) { return cb(err) } |
|
|
|
|
|
|
|
connection.listCollections().toArray(function (err, collections) { |
|
|
|
if (err) { return cb(err) } |
|
|
|
cb(null, collections.map(mapCollectionNames)) |
|
|
|
cb(null, collections) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
Database.prototype.getCollectionNames = function (cb) { |
|
|
|
this.listCollections(function (err, collections) { |
|
|
|
if (err) { return cb(err) } |
|
|
|
cb(null, collections.map(function (collection) { return collection.name })) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
Database.prototype.createCollection = function (name, opts, cb) { |
|
|
|
if (typeof opts === 'function') return this.createCollection(name, {}, opts) |
|
|
|
|
|
|
|