Skip to content

Commit

Permalink
use promises at adapter getExecutedMigrationNames method
Browse files Browse the repository at this point in the history
  • Loading branch information
okv committed Dec 27, 2019
1 parent 321d2d5 commit 55b2109
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
12 changes: 5 additions & 7 deletions lib/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,11 @@ Adapter.prototype.disconnect = function() {
};

Adapter.prototype.getExecutedMigrationNames = function(callback) {
this.collection.find({}).toArray(function(err, docs) {
if (err) {
return callback(err);
}

callback(null, docs.map(function(doc) { return doc._id; }));
});
return Promise.resolve()
.then(() => this.collection.find({}).toArray())
.then((docs) => {
return docs.map((doc) => doc._id);
});
};

Adapter.prototype.markExecuted = function(name, callback) {
Expand Down
3 changes: 0 additions & 3 deletions test/utils/createAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ module.exports = () => {

const adapter = new Adapter(defaultParams);

adapter.getExecutedMigrationNames = promisify(
adapter.getExecutedMigrationNames.bind(adapter)
);
adapter.helpers.dropIndexIfExists = promisify(
adapter.helpers.dropIndexIfExists
);
Expand Down

0 comments on commit 55b2109

Please sign in to comment.