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

      const { id, users, organizationId } = params
      const tasks = [
        (job, next) => {
          Joi.validate({ id, users, organizationId }, validationRules.addUsersToTeam, (err) => {
            if (err) return next(Boom.badRequest(err))
            next()
          })
        },
        (job, next) => {
          job.teamId = id
          job.organizationId = organizationId
          job.params = params

          next()
        },
        (job, next) => {
          utils.checkUsersOrg(job.client, job.params.users, job.organizationId, next)
        },
        checkTeamExists,
        insertTeamMembers
      ]

      db.withTransaction(tasks, (err, res) => {
        if (err) return cb(err)
        teamOps.readTeam({ id, organizationId }, cb)
      })

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

      const { id, users, organizationId } = params
      const tasks = [
        (job, next) => {
          Joi.validate({ id, users, organizationId }, validationRules.addUsersToTeam, (err) => {
            if (err) return next(Boom.badRequest(err))
            next()
          })
        },
        (job, next) => {
          job.teamId = id
          job.organizationId = organizationId
          job.params = params

          next()
        },
        (job, next) => {
          utils.checkUsersOrg(job.client, job.params.users, job.organizationId, next)
        },
        checkTeamExists,
        insertTeamMembers
      ]

      db.withTransaction(tasks, (err, res) => {
        if (err) return cb(err)
        teamOps.readTeam({ id, organizationId }, cb)
      })

      return promise
    }
function addUsersToTeam ( params , cb ) { let promise = null if ( typeof cb !== 'function' ) [ promise , cb ] = asyncify ( ) const { id , users , organizationId } = params const tasks = [ ( job , next ) => { Joi . validate ( { id , users , organizationId } , validationRules . addUsersToTeam , ( err ) => { if ( err ) return next ( Boom . badRequest ( err ) ) next ( ) } ) } , ( job , next ) => { job . teamId = id job . organizationId = organizationId job . params = params next ( ) } , ( job , next ) => { utils . checkUsersOrg ( job . client , job . params . users , job . organizationId , next ) } , checkTeamExists , insertTeamMembers ] db . withTransaction ( tasks , ( err , res ) => { if ( err ) return cb ( err ) teamOps . readTeam ( { id , organizationId } , cb ) } ) return promise }
Add one or more users to a team

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