lib/startApplication.js
function setUpInjectObjectTemplate(appName, config, schema) {
    let amorphicOptions = AmorphicContext.amorphicOptions || {};
    let dbConfig = buildDbConfig(appName, config);
    let connectToDbIfNeedBe = Bluebird.resolve(false); // Default to no need.

    if (dbConfig.dbName && dbConfig.dbPath) {
        if (dbConfig.dbDriver === 'mongo') {
            let MongoClient = require('mongodb-bluebird');
            connectToDbIfNeedBe = MongoClient.connect(dbConfig.dbPath + dbConfig.dbName);
        }
        else if (dbConfig.dbDriver === 'knex') {
            let knex = require('knex')({
                client: dbConfig.dbType,
                debug: dbConfig.knexDebug,
                connection: {
                    host:       dbConfig.dbPath,
                    database:   dbConfig.dbName,
                    user:       dbConfig.dbUser,
                    password:   dbConfig.dbPassword,
                    port: dbConfig.dbPort,
                    application_name: appName
                },
                pool: {
                    min: 0,
                    max: dbConfig.dbConnections
                },
                acquireConnectionTimeout: dbConfig.dbConnectionTimeout
            });

            connectToDbIfNeedBe = Bluebird.resolve(knex); // require('knex') is a synchronous call that already connects
        }
    }

    return connectToDbIfNeedBe
        .then(returnBoundInjectTemplate.bind(this, amorphicOptions, config, dbConfig, schema));
}
function setUpInjectObjectTemplate(appName, config, schema) {
    let amorphicOptions = AmorphicContext.amorphicOptions || {};
    let dbConfig = buildDbConfig(appName, config);
    let connectToDbIfNeedBe = Bluebird.resolve(false); // Default to no need.

    if (dbConfig.dbName && dbConfig.dbPath) {
        if (dbConfig.dbDriver === 'mongo') {
            let MongoClient = require('mongodb-bluebird');
            connectToDbIfNeedBe = MongoClient.connect(dbConfig.dbPath + dbConfig.dbName);
        }
        else if (dbConfig.dbDriver === 'knex') {
            let knex = require('knex')({
                client: dbConfig.dbType,
                debug: dbConfig.knexDebug,
                connection: {
                    host:       dbConfig.dbPath,
                    database:   dbConfig.dbName,
                    user:       dbConfig.dbUser,
                    password:   dbConfig.dbPassword,
                    port: dbConfig.dbPort,
                    application_name: appName
                },
                pool: {
                    min: 0,
                    max: dbConfig.dbConnections
                },
                acquireConnectionTimeout: dbConfig.dbConnectionTimeout
            });

            connectToDbIfNeedBe = Bluebird.resolve(knex); // require('knex') is a synchronous call that already connects
        }
    }

    return connectToDbIfNeedBe
        .then(returnBoundInjectTemplate.bind(this, amorphicOptions, config, dbConfig, schema));
}
function setUpInjectObjectTemplate ( appName , config , schema ) { let amorphicOptions = AmorphicContext . amorphicOptions || { } ; let dbConfig = buildDbConfig ( appName , config ) ; let connectToDbIfNeedBe = Bluebird . resolve ( false ) ; // Default to no need. if ( dbConfig . dbName && dbConfig . dbPath ) { if ( dbConfig . dbDriver === 'mongo' ) { let MongoClient = require ( 'mongodb-bluebird' ) ; connectToDbIfNeedBe = MongoClient . connect ( dbConfig . dbPath + dbConfig . dbName ) ; } else if ( dbConfig . dbDriver === 'knex' ) { let knex = require ( 'knex' ) ( { client : dbConfig . dbType , debug : dbConfig . knexDebug , connection : { host : dbConfig . dbPath , database : dbConfig . dbName , user : dbConfig . dbUser , password : dbConfig . dbPassword , port : dbConfig . dbPort , application_name : appName } , pool : { min : 0 , max : dbConfig . dbConnections } , acquireConnectionTimeout : dbConfig . dbConnectionTimeout } ) ; connectToDbIfNeedBe = Bluebird . resolve ( knex ) ; // require('knex') is a synchronous call that already connects } } return connectToDbIfNeedBe . then ( returnBoundInjectTemplate . bind ( this , amorphicOptions , config , dbConfig , schema ) ) ; }
Sets up the injectObjectTemplate function used when loading templates to make them PersistableSemotable or
simply Persistable.

@param {String} appName - The app name.
@param {Object} config - The app specific config from the config store.
@param {String} schema - The app schema.

@returns {Function} A bound function to be used when loading templates.
Sets up the injectObjectTemplate function used when loading templates to make them PersistableSemotable or simply Persistable .