registry.js
function setDatabaseSecurity(name, cb) {
  // Get _security first
  getSecurity(name, function(err, d) {
    if(err) return cb(err)
    
    // Make name an admin
    if(d.admins.names.indexOf(name) === -1) {
      d.admins.names.push(name)
    }
    
    // Make name a reader
    if(d.readers.names.indexOf(name) === -1) {
      d.readers.names.push(name)
    }
    
    // Merge with _security template
    d = mergeSecurity(_security, d)
    
    // Apply changes
    setSecurity(name, d, function(err) {
      if(err) return cb(err)
      cb()
    })
  })
}
function setDatabaseSecurity(name, cb) {
  // Get _security first
  getSecurity(name, function(err, d) {
    if(err) return cb(err)
    
    // Make name an admin
    if(d.admins.names.indexOf(name) === -1) {
      d.admins.names.push(name)
    }
    
    // Make name a reader
    if(d.readers.names.indexOf(name) === -1) {
      d.readers.names.push(name)
    }
    
    // Merge with _security template
    d = mergeSecurity(_security, d)
    
    // Apply changes
    setSecurity(name, d, function(err) {
      if(err) return cb(err)
      cb()
    })
  })
}
function setDatabaseSecurity ( name , cb ) { // Get _security first getSecurity ( name , function ( err , d ) { if ( err ) return cb ( err ) // Make name an admin if ( d . admins . names . indexOf ( name ) === - 1 ) { d . admins . names . push ( name ) } // Make name a reader if ( d . readers . names . indexOf ( name ) === - 1 ) { d . readers . names . push ( name ) } // Merge with _security template d = mergeSecurity ( _security , d ) // Apply changes setSecurity ( name , d , function ( err ) { if ( err ) return cb ( err ) cb ( ) } ) } ) }
Sets the _security document of a database
Sets the _security document of a database