lib/transactions.js
function (connectionName, callback) {
        var self = this,
            conn = self.connection();

        // if not yet connected, spawn new connection and initiate transaction
        if (!conn) {
            self.connect(connectionName, function (error, conn) {
                if (error) {
                    callback(error, conn);
                    return;
                }
                // now that we have the connection, we initiate transaction. note that this sql_start is part of the new
                // connection branch. it is always highly likely that this would be the program flow. in a very unlikely
                // case the alternate flow will kick in, which is the `conn.query` right after this if-block.
                conn.beginTransaction(function (error) {
                    callback(error, self);
                });
            });

            return; // do not proceed with sql_start if connection wasn't initially present.
        }

        // if transaction is attempted across multiple connections, return an error
        if (connectionName !== self._connectionName) {
            return callback(new AdapterError(AdapterError.TRANSACTION_MULTI_DB_CONNECTION_ATTEMPTED));
        }

        conn.beginTransaction(function (error) {
            // if callback mode is used, then execute it and send self as a parameter to match the new Constructor API.
            callback(error, self);
        });
    }
function (connectionName, callback) {
        var self = this,
            conn = self.connection();

        // if not yet connected, spawn new connection and initiate transaction
        if (!conn) {
            self.connect(connectionName, function (error, conn) {
                if (error) {
                    callback(error, conn);
                    return;
                }
                // now that we have the connection, we initiate transaction. note that this sql_start is part of the new
                // connection branch. it is always highly likely that this would be the program flow. in a very unlikely
                // case the alternate flow will kick in, which is the `conn.query` right after this if-block.
                conn.beginTransaction(function (error) {
                    callback(error, self);
                });
            });

            return; // do not proceed with sql_start if connection wasn't initially present.
        }

        // if transaction is attempted across multiple connections, return an error
        if (connectionName !== self._connectionName) {
            return callback(new AdapterError(AdapterError.TRANSACTION_MULTI_DB_CONNECTION_ATTEMPTED));
        }

        conn.beginTransaction(function (error) {
            // if callback mode is used, then execute it and send self as a parameter to match the new Constructor API.
            callback(error, self);
        });
    }
function ( connectionName , callback ) { var self = this , conn = self . connection ( ) ; // if not yet connected, spawn new connection and initiate transaction if ( ! conn ) { self . connect ( connectionName , function ( error , conn ) { if ( error ) { callback ( error , conn ) ; return ; } // now that we have the connection, we initiate transaction. note that this sql_start is part of the new // connection branch. it is always highly likely that this would be the program flow. in a very unlikely // case the alternate flow will kick in, which is the `conn.query` right after this if-block. conn . beginTransaction ( function ( error ) { callback ( error , self ) ; } ) ; } ) ; return ; // do not proceed with sql_start if connection wasn't initially present. } // if transaction is attempted across multiple connections, return an error if ( connectionName !== self . _connectionName ) { return callback ( new AdapterError ( AdapterError . TRANSACTION_MULTI_DB_CONNECTION_ATTEMPTED ) ) ; } conn . beginTransaction ( function ( error ) { // if callback mode is used, then execute it and send self as a parameter to match the new Constructor API. callback ( error , self ) ; } ) ; }
Start a new transaction.

@param connectionName
@param callback
Start a new transaction .