Fix #422, transactions & Bluebird 2.3

This commit is contained in:
Tim Griesser 2014-08-14 14:56:16 -04:00
parent 6f4a976944
commit 6bc918f300

View File

@ -73,18 +73,21 @@ require('./interface')(Transaction);
// Passed a `container` function, this method runs the current
// transaction, returning a promise.
Transaction.prototype.then = function(onFulfilled, onRejected) {
var Runner = this.client.Runner;
var Runner = this.client.Runner;
var promise = this;
// Create a new "runner" object, passing the "runner"
// object along, so we can easily keep track of every
// query run on the current connection.
return new Runner(this)
.startTransaction()
.bind(this)
.then(this.containerObject)
.then(this.initiateDeferred)
.then(onFulfilled, onRejected)
.bind();
.then(function(obj) {
return promise.containerObject(obj);
})
.then(function(obj) {
return promise.initiateDeferred(obj);
})
.then(onFulfilled, onRejected);
};
module.exports = Transaction;