Skip to content

Commit

Permalink
wait for promises to finish,
Browse files Browse the repository at this point in the history
closes #120
  • Loading branch information
officert committed Mar 2, 2016
1 parent 7df3f17 commit 23b6276
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/lib/entities/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,19 @@ class Database {
this._dbConnection.collections((err, collections) => {
if (err) return reject(new errors.DatabaseError(err.message));

let promises = [];

_.each(collections, (collection) => {
this.addCollection({
promises.push(this.addCollection({
name: collection.collectionName
});
}));
});

return resolve(this.collections);
Promise
.all(promises)
.then(() => {
return resolve(this.collections);
});
});
});
}
Expand Down

0 comments on commit 23b6276

Please sign in to comment.