lib/connections/register.js
/**
   * Register a connection (and the collections assigned to it) with the MySQL adapter.
   *
   * @param  {Connection} connection
   * @param  {Object} collections
   * @param  {Function} cb
   */
Register a connection (and the collections assigned to it) with the MySQL adapter.
Register a connection ( and the collections assigned to it ) with the MySQL adapter .
function registerConnection (connection, collections, cb) {
    if(!connection.identity) return cb(Errors.IdentityMissing);
    if(connections[connection.identity]) return cb(Errors.IdentityDuplicate);
    Object.keys(collections).forEach(function(coll) {
      collections[coll].schema = collections[coll].definition;
    });
    connections[connection.identity] = {
      config: connection,
      collections: collections,
      connection: {}
    };
    var activeConnection = connections[connection.identity];
    if (activeConnection.config.pool) {
      activeConnection.connection.pool = mysql.createPool(activeConnection.config);
      activeConnection.connection.releaseConnection = _releaseConnection.poolfully;
    }
    else {
      activeConnection.connection.releaseConnection = _releaseConnection.poollessly;
    }
    return cb();
  }
function registerConnection ( connection , collections , cb ) { if ( ! connection . identity ) return cb ( Errors . IdentityMissing ) ; if ( connections [ connection . identity ] ) return cb ( Errors . IdentityDuplicate ) ; Object . keys ( collections ) . forEach ( function ( coll ) { collections [ coll ] . schema = collections [ coll ] . definition ; } ) ; connections [ connection . identity ] = { config : connection , collections : collections , connection : { } } ; var activeConnection = connections [ connection . identity ] ; if ( activeConnection . config . pool ) { activeConnection . connection . pool = mysql . createPool ( activeConnection . config ) ; activeConnection . connection . releaseConnection = _releaseConnection . poolfully ; } else { activeConnection . connection . releaseConnection = _releaseConnection . poollessly ; } return cb ( ) ; }
Register a connection (and the collections assigned to it) with the MySQL adapter.
Register a connection ( and the collections assigned to it ) with the MySQL adapter .
// Validate arguments // Always ensure the schema key is set to something. This should be remapped in the // .describe() method later on. // Store the connection // Create a connection pool if configured to do so. // (and set up the necessary `releaseConnection` functionality to drain it.) // Otherwise, assign some default releaseConnection functionality. // Done!  The WLConnection (and all of it's collections) have been loaded.