Skip to content

Commit

Permalink
add missing error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
pmlopes committed May 21, 2012
1 parent 9e9a954 commit b59006f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/index.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -107,13 +107,21 @@ var ODM = {
*/ */
removeAllCollections: function(callback) { removeAllCollections: function(callback) {
var self = this; var self = this;
this.db.collectionNames(function(err, collectionNames) { this.db.collectionNames(function (err, collectionNames) {
if (err) {
return callback(err);
}

var counter = collectionNames.length; var counter = collectionNames.length;
collectionNames.forEach(function(collectionName, i) {
self.db.dropCollection( collectionNames.forEach(function (collectionName) {
collectionName.name.substr(collectionName.name.lastIndexOf('.')+1), function(err, result) { self.db.dropCollection(collectionName.name.substr(collectionName.name.lastIndexOf('.') + 1), function (err) {
if (err) {
return callback(err);
}

if (--counter === 0) { if (--counter === 0) {
callback(); callback(null);
} }
}); });
}); });
Expand Down

0 comments on commit b59006f

Please sign in to comment.