lib/transactions.js
function (callback) {
        var conn = this.connection(),
            id = this._id; // use the raw ID object

        // prevent new transactions from using this connection.
        this.disconnect();

        // if commit was called with no active conn, it implies, no transact action
        // was called. as such it is an error.
        if (!conn) {
            // allow one pseudo commit even without connection, so that programmatic call of repeated commits or
            // rollbacks can be trapped.
            // note that the absence of `_id` indicates that a `.disconnect` was called.
            return callback && callback(id ? null : new AdapterError(AdapterError.TRANSACTION_UNINITIATED_COMM));
        }

        // we commit the connection and then release from hash
        conn.commit(function (error) {
            // try releasing the connection.
            // if that fails then treat it as a major error.
            try {
                conn.release();
            }
            // if there was an error during release, set that as the main error.
            catch (err) {
                !error && (error = err);
            }

            // if failure to issue commit or release, then rollback
            if (error && conn.transactionConfig.rollbackOnError) {
                return conn.rollback(function () {
                    // disassociate the connection from transaction and execute callback
                    Transaction.disassociateConnection(conn);
                    callback && callback(error);
                });
            }

            // disassociate the connection from transaction and execute callback
            Transaction.disassociateConnection(conn);
            callback && callback(error);
        });
    }
function (callback) {
        var conn = this.connection(),
            id = this._id; // use the raw ID object

        // prevent new transactions from using this connection.
        this.disconnect();

        // if commit was called with no active conn, it implies, no transact action
        // was called. as such it is an error.
        if (!conn) {
            // allow one pseudo commit even without connection, so that programmatic call of repeated commits or
            // rollbacks can be trapped.
            // note that the absence of `_id` indicates that a `.disconnect` was called.
            return callback && callback(id ? null : new AdapterError(AdapterError.TRANSACTION_UNINITIATED_COMM));
        }

        // we commit the connection and then release from hash
        conn.commit(function (error) {
            // try releasing the connection.
            // if that fails then treat it as a major error.
            try {
                conn.release();
            }
            // if there was an error during release, set that as the main error.
            catch (err) {
                !error && (error = err);
            }

            // if failure to issue commit or release, then rollback
            if (error && conn.transactionConfig.rollbackOnError) {
                return conn.rollback(function () {
                    // disassociate the connection from transaction and execute callback
                    Transaction.disassociateConnection(conn);
                    callback && callback(error);
                });
            }

            // disassociate the connection from transaction and execute callback
            Transaction.disassociateConnection(conn);
            callback && callback(error);
        });
    }
function ( callback ) { var conn = this . connection ( ) , id = this . _id ; // use the raw ID object // prevent new transactions from using this connection. this . disconnect ( ) ; // if commit was called with no active conn, it implies, no transact action // was called. as such it is an error. if ( ! conn ) { // allow one pseudo commit even without connection, so that programmatic call of repeated commits or // rollbacks can be trapped. // note that the absence of `_id` indicates that a `.disconnect` was called. return callback && callback ( id ? null : new AdapterError ( AdapterError . TRANSACTION_UNINITIATED_COMM ) ) ; } // we commit the connection and then release from hash conn . commit ( function ( error ) { // try releasing the connection. // if that fails then treat it as a major error. try { conn . release ( ) ; } // if there was an error during release, set that as the main error. catch ( err ) { ! error && ( error = err ) ; } // if failure to issue commit or release, then rollback if ( error && conn . transactionConfig . rollbackOnError ) { return conn . rollback ( function ( ) { // disassociate the connection from transaction and execute callback Transaction . disassociateConnection ( conn ) ; callback && callback ( error ) ; } ) ; } // disassociate the connection from transaction and execute callback Transaction . disassociateConnection ( conn ) ; callback && callback ( error ) ; } ) ; }
Commit the transaction
@param {function} callback - receives `error`
Commit the transaction