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

      const { id, name, description, metadata, organizationId } = params

      Joi.validate({ id, name, description, organizationId, metadata }, Joi.object().keys(validationRules.updateTeam).or('name', 'description'), function (err) {
        if (err) return cb(Boom.badRequest(err))

        const updates = []
        const sql = SQL` UPDATE teams SET `
        if (name) { updates.push(SQL`name = ${name}`) }
        if (description) { updates.push(SQL`description = ${description}`) }
        if (metadata) { updates.push(SQL`metadata = ${metadata}`) }
        sql.append(sql.glue(updates, ' , '))
        sql.append(SQL`
          WHERE id = ${id}
          AND org_id = ${organizationId}
        `)

        db.query(sql, (err, res) => {
          if (utils.isUniqueViolationError(err)) return cb(Boom.conflict(err.detail))
          if (err) return cb(Boom.badImplementation(err))
          if (res.rowCount === 0) return cb(Boom.notFound(`Team with id ${id} could not be found`))

          teamOps.readTeam({ id, organizationId }, cb)
        })
      })

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

      const { id, name, description, metadata, organizationId } = params

      Joi.validate({ id, name, description, organizationId, metadata }, Joi.object().keys(validationRules.updateTeam).or('name', 'description'), function (err) {
        if (err) return cb(Boom.badRequest(err))

        const updates = []
        const sql = SQL` UPDATE teams SET `
        if (name) { updates.push(SQL`name = ${name}`) }
        if (description) { updates.push(SQL`description = ${description}`) }
        if (metadata) { updates.push(SQL`metadata = ${metadata}`) }
        sql.append(sql.glue(updates, ' , '))
        sql.append(SQL`
          WHERE id = ${id}
          AND org_id = ${organizationId}
        `)

        db.query(sql, (err, res) => {
          if (utils.isUniqueViolationError(err)) return cb(Boom.conflict(err.detail))
          if (err) return cb(Boom.badImplementation(err))
          if (res.rowCount === 0) return cb(Boom.notFound(`Team with id ${id} could not be found`))

          teamOps.readTeam({ id, organizationId }, cb)
        })
      })

      return promise
    }
function updateTeam ( params , cb ) { let promise = null if ( typeof cb !== 'function' ) [ promise , cb ] = asyncify ( ) const { id , name , description , metadata , organizationId } = params Joi . validate ( { id , name , description , organizationId , metadata } , Joi . object ( ) . keys ( validationRules . updateTeam ) . or ( 'name' , 'description' ) , function ( err ) { if ( err ) return cb ( Boom . badRequest ( err ) ) const updates = [ ] const sql = SQL ` ` if ( name ) { updates . push ( SQL ` ${ name } ` ) } if ( description ) { updates . push ( SQL ` ${ description } ` ) } if ( metadata ) { updates . push ( SQL ` ${ metadata } ` ) } sql . append ( sql . glue ( updates , ' , ' ) ) sql . append ( SQL ` ${ id } ${ organizationId } ` ) db . query ( sql , ( err , res ) => { if ( utils . isUniqueViolationError ( err ) ) return cb ( Boom . conflict ( err . detail ) ) if ( err ) return cb ( Boom . badImplementation ( err ) ) if ( res . rowCount === 0 ) return cb ( Boom . notFound ( ` ${ id } ` ) ) teamOps . readTeam ( { id , organizationId } , cb ) } ) } ) return promise }
Uodate team data
@param {Object}   params {id, name, description, metadata, organizationId } "metadata" optional
@param {Function} cb
Uodate team data