packages/udaru-core/lib/ops/teamOps.js
function addTeamPolicies (params, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      const { id, organizationId } = params

      Joi.validate({ id, organizationId, policies: params.policies }, validationRules.addTeamPolicies, function (err) {
        if (err) return cb(Boom.badRequest(err))

        const policies = utils.preparePolicies(params.policies)

        utils.checkPoliciesOrg(db, policies, organizationId, (err) => {
          if (err) return cb(err)

          insertTeamPolicies({ client: db, teamId: id, policies }, (err, res) => {
            if (err) return cb(err)
            teamOps.readTeam({ id, organizationId }, cb)
          })
        })
      })

      return promise
    }
function addTeamPolicies (params, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      const { id, organizationId } = params

      Joi.validate({ id, organizationId, policies: params.policies }, validationRules.addTeamPolicies, function (err) {
        if (err) return cb(Boom.badRequest(err))

        const policies = utils.preparePolicies(params.policies)

        utils.checkPoliciesOrg(db, policies, organizationId, (err) => {
          if (err) return cb(err)

          insertTeamPolicies({ client: db, teamId: id, policies }, (err, res) => {
            if (err) return cb(err)
            teamOps.readTeam({ id, organizationId }, cb)
          })
        })
      })

      return promise
    }
function addTeamPolicies ( params , cb ) { let promise = null if ( typeof cb !== 'function' ) [ promise , cb ] = asyncify ( ) const { id , organizationId } = params Joi . validate ( { id , organizationId , policies : params . policies } , validationRules . addTeamPolicies , function ( err ) { if ( err ) return cb ( Boom . badRequest ( err ) ) const policies = utils . preparePolicies ( params . policies ) utils . checkPoliciesOrg ( db , policies , organizationId , ( err ) => { if ( err ) return cb ( err ) insertTeamPolicies ( { client : db , teamId : id , policies } , ( err , res ) => { if ( err ) return cb ( err ) teamOps . readTeam ( { id , organizationId } , cb ) } ) } ) } ) return promise }
Add one or more policies to a team

@param  {Object}   params { id, organizationId, policies }
@param  {Function} cb
Add one or more policies to a team