Skip to content

Commit 419add6

Browse files
vvandensachrinza
authored andcommitted
fix: #900 replace callback implementation by the promise one
Signed-off-by: Vincent Vandenschrick <vvandens@gmail.com>
1 parent 09f1508 commit 419add6

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

lib/mongodb.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2349,23 +2349,17 @@ MongoDB.prototype.beginTransaction = function(isolationLevel, cb) {
23492349
};
23502350

23512351
MongoDB.prototype.commit = function(tx, cb) {
2352-
tx.commitTransaction(function(err) {
2353-
tx.endSession(null, function(error) {
2354-
if (err) return cb(err);
2355-
if (error) return cb(error);
2356-
cb();
2357-
});
2358-
});
2352+
tx.commitTransaction()
2353+
.then(() => tx.endSession())
2354+
.then(() => cb())
2355+
.catch((err) => cb(err));
23592356
};
23602357

23612358
MongoDB.prototype.rollback = function(tx, cb) {
2362-
tx.abortTransaction(function(err) {
2363-
tx.endSession(null, function(error) {
2364-
if (err) return cb(err);
2365-
if (error) return cb(error);
2366-
cb();
2367-
});
2368-
});
2359+
tx.abortTransaction()
2360+
.then(() => tx.endSession())
2361+
.then(() => cb())
2362+
.catch((err) => cb(err));
23692363
};
23702364

23712365
function isInTransation(options) {

0 commit comments

Comments
 (0)