registry.js
function connectUser(name, pass, cb) {
  loginUser(name, pass, function(err, user) {
    if(err) return cb(err)
    
    var nano = NANO(_ci.protocol+'//'+encodeURIComponent(name)+':'+encodeURIComponent(pass)+'@'+_ci.host+'/')
      , db = nano.use(name)
      ;
    
    function getObject(type, id, rev) {
      var ctor = registry[type]
        , obj = new ctor(id, rev)
      obj.type(type)
      if(ctor.dbname) {
        obj.db = nano.use(ctor.dbname)
      } else {
        obj.db = db
      }
      obj.getObject = getObject
      return obj
    }
    
    cb(null, user, getObject, db, nano)
  })
}
function connectUser(name, pass, cb) {
  loginUser(name, pass, function(err, user) {
    if(err) return cb(err)
    
    var nano = NANO(_ci.protocol+'//'+encodeURIComponent(name)+':'+encodeURIComponent(pass)+'@'+_ci.host+'/')
      , db = nano.use(name)
      ;
    
    function getObject(type, id, rev) {
      var ctor = registry[type]
        , obj = new ctor(id, rev)
      obj.type(type)
      if(ctor.dbname) {
        obj.db = nano.use(ctor.dbname)
      } else {
        obj.db = db
      }
      obj.getObject = getObject
      return obj
    }
    
    cb(null, user, getObject, db, nano)
  })
}
function connectUser ( name , pass , cb ) { loginUser ( name , pass , function ( err , user ) { if ( err ) return cb ( err ) var nano = NANO ( _ci . protocol + '//' + encodeURIComponent ( name ) + ':' + encodeURIComponent ( pass ) + '@' + _ci . host + '/' ) , db = nano . use ( name ) ; function getObject ( type , id , rev ) { var ctor = registry [ type ] , obj = new ctor ( id , rev ) obj . type ( type ) if ( ctor . dbname ) { obj . db = nano . use ( ctor . dbname ) } else { obj . db = db } obj . getObject = getObject return obj } cb ( null , user , getObject , db , nano ) } ) }
Connects a user
Connects a user