lib/transactions.js
function (config) {
        // at this stage, the `db` variable should not exist. expecting fresh setup or post teardown setup.
        if (Transaction.databases[config.identity]) {
            // @todo - emit wrror event instead of console.log
            console.log('Warn: duplicate setup of connection found in Transactions.setup');
            this.teardown();
        }

        var _db;

        // clone the configuration
        config = util.clone(config);
        delete config.replication;

        // allow special transaction related config
        util.each(config, function (value, name, config) {
            if (!/^transaction.+/g.test(name)) { return; }

            // remove transaction config prefix
            var baseName = name.replace(/^transaction/g, '');
            baseName = baseName.charAt(0).toLowerCase() + baseName.slice(1);

            delete config[name];
            config[baseName] = value;
        });

        _db = db.createSource(config);

        // Save a few configurations
        _db && (_db.transactionConfig = {
            rollbackOnError: config.rollbackTransactionOnError
        });

        Transaction.databases[config.identity] = _db;
    }
function (config) {
        // at this stage, the `db` variable should not exist. expecting fresh setup or post teardown setup.
        if (Transaction.databases[config.identity]) {
            // @todo - emit wrror event instead of console.log
            console.log('Warn: duplicate setup of connection found in Transactions.setup');
            this.teardown();
        }

        var _db;

        // clone the configuration
        config = util.clone(config);
        delete config.replication;

        // allow special transaction related config
        util.each(config, function (value, name, config) {
            if (!/^transaction.+/g.test(name)) { return; }

            // remove transaction config prefix
            var baseName = name.replace(/^transaction/g, '');
            baseName = baseName.charAt(0).toLowerCase() + baseName.slice(1);

            delete config[name];
            config[baseName] = value;
        });

        _db = db.createSource(config);

        // Save a few configurations
        _db && (_db.transactionConfig = {
            rollbackOnError: config.rollbackTransactionOnError
        });

        Transaction.databases[config.identity] = _db;
    }
function ( config ) { // at this stage, the `db` variable should not exist. expecting fresh setup or post teardown setup. if ( Transaction . databases [ config . identity ] ) { // @todo - emit wrror event instead of console.log console . log ( 'Warn: duplicate setup of connection found in Transactions.setup' ) ; this . teardown ( ) ; } var _db ; // clone the configuration config = util . clone ( config ) ; delete config . replication ; // allow special transaction related config util . each ( config , function ( value , name , config ) { if ( ! / ^transaction.+ / g . test ( name ) ) { return ; } // remove transaction config prefix var baseName = name . replace ( / ^transaction / g , '' ) ; baseName = baseName . charAt ( 0 ) . toLowerCase ( ) + baseName . slice ( 1 ) ; delete config [ name ] ; config [ baseName ] = value ; } ) ; _db = db . createSource ( config ) ; // Save a few configurations _db && ( _db . transactionConfig = { rollbackOnError : config . rollbackTransactionOnError } ) ; Transaction . databases [ config . identity ] = _db ; }
For first run, the transactions environment needs to be setup. Without that, it is not possible to procure new
database connections.
For first run the transactions environment needs to be setup . Without that it is not possible to procure new database connections .