lib/adapter.js
function (connection, collections, cb) {

      if (!connection.identity) return cb(Errors.IdentityMissing);
      if (connections[connection.identity]) return cb(Errors.IdentityDuplicate);

      // Store the connection
      connections[connection.identity] = {
        config: connection,
        collections: collections,
        client: null
      };


      // connect to database
      new Connection(connection, function (err, client) {

        if (err) return cb(err);

        connections[connection.identity].client = client;

        // Build up a registry of collections
        Object.keys(collections).forEach(function (key) {
          connections[connection.identity].collections[key] = new Collection(collections[key], client);
        });

        // execute callback
        cb();
      });

    }
function (connection, collections, cb) {

      if (!connection.identity) return cb(Errors.IdentityMissing);
      if (connections[connection.identity]) return cb(Errors.IdentityDuplicate);

      // Store the connection
      connections[connection.identity] = {
        config: connection,
        collections: collections,
        client: null
      };


      // connect to database
      new Connection(connection, function (err, client) {

        if (err) return cb(err);

        connections[connection.identity].client = client;

        // Build up a registry of collections
        Object.keys(collections).forEach(function (key) {
          connections[connection.identity].collections[key] = new Collection(collections[key], client);
        });

        // execute callback
        cb();
      });

    }
function ( connection , collections , cb ) { if ( ! connection . identity ) return cb ( Errors . IdentityMissing ) ; if ( connections [ connection . identity ] ) return cb ( Errors . IdentityDuplicate ) ; // Store the connection connections [ connection . identity ] = { config : connection , collections : collections , client : null } ; // connect to database new Connection ( connection , function ( err , client ) { if ( err ) return cb ( err ) ; connections [ connection . identity ] . client = client ; // Build up a registry of collections Object . keys ( collections ) . forEach ( function ( key ) { connections [ connection . identity ] . collections [ key ] = new Collection ( collections [ key ] , client ) ; } ) ; // execute callback cb ( ) ; } ) ; }
Register a connection and the collections assigned to it.

@param  {Connection} connection
@param  {Object} collections
@param  {Function} cb
Register a connection and the collections assigned to it .