function Transaction(sequelize) {
    this.adapter = sequelize;
    this.inTransaction = false;

    sequelize.trx = this;
}

Transaction.prototype.start = function(callback) {
    if (!this.inTransaction) {
        this.inTransaction = true;

        this.adapter.query('BEGIN')
            .success(callback)
            .error(callback);
    }
}

Transaction.prototype.commit = function(callback) {
    var self = this;

    if (this.inTransaction) {
        this.adapter.query('COMMIT')
            .success(function () {
                self.inTransaction = false;
                if (callback) callback();
            })
            .error(function (error) {
                self.inTransaction = false;
                if (callback) callback(error);
                throw error;
            });
    }    
}

Transaction.prototype.rollback = function(callback) {
    var self = this;

    if (this.inTransaction) {
        this.adapter.query('ROLLBACK')
            .success(function () {
                self.inTransaction = false;   
                if (callback) callback(); 
            })
            .error(function (error) {
                self.inTransaction = false;
                if (callback) callback(error);
                throw error;
            });
    }  
}

Transaction.prototype.waitTransaction = function(callback, waitTimeout) {

    var self = this;
    waitTimeout = waitTimeout || 10;

    function checkInTransaction() {
        if (self.inTransaction) {
            // console.log('Waiting...');
            setTimeout(checkInTransaction, waitTimeout);
        } else
            process.nextTick(callback);
    }

    checkInTransaction();
}

Transaction.useTransaction = function(sequelize) {
    return new Transaction(sequelize);
}

exports.Transaction = Transaction;

@@ -154,36 +154,104 @@
  = function(
-callback) %7B%0A
+waitTransaction, callback) %7B%0A    var self = this;%0A%0A    function doStart() %7B%0A    
     if (!thi
@@ -247,20 +247,20 @@
    if (!
-this
+self
 .inTrans
@@ -273,28 +273,32 @@
 ) %7B%0A        
-this
+    self
 .inTransacti
@@ -309,36 +309,267 @@
  true;%0A%0A        
-this
+    self.adapter.query('BEGIN')%0A                .success(callback)%0A                .error(callback);%0A        %7D else %7B%0A            if (waitTransaction)%0A                self.waitTransaction(doStart);%0A            else%0A                self
 .adapter.query('
@@ -580,32 +580,40 @@
 N')%0A            
+ 
+       
 .success(callbac
@@ -619,32 +619,40 @@
 ck)%0A            
+     
+   
 .error(callback)
@@ -657,17 +657,47 @@
 k);%0A    
-%7D
+    %7D    %0A    %7D%0A%0A    doStart();
 %0A%7D%0A%0ATran
@@ -1760,9 +1760,8 @@
 %7C%7C 1
-0
 ;%0A%0A 
@@ -1894,16 +1894,62 @@
 Timeout(
+function() %7B%0A                process.nextTick(
 checkInT
@@ -1958,16 +1958,31 @@
 nsaction
+)%0A            %7D
 , waitTi

Update transactions.js