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

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

      Joi.validate({ id, organizationId, name, metadata }, validationRules.updateUser, function (err) {
        if (err) return cb(Boom.badRequest(err))

        const sqlQuery = SQL`
          UPDATE users
          SET name = ${name},
          metadata = ${metadata}
          WHERE id = ${id}
          AND org_id = ${organizationId}
        `
        db.query(sqlQuery, (err, result) => {
          if (utils.isUniqueViolationError(err)) return cb(Boom.conflict(err.detail))
          if (err) return cb(Boom.badImplementation(err))
          if (result.rowCount === 0) return cb(Boom.notFound(`User ${id} not found`))

          userOps.readUser({ id, organizationId }, cb)
        })
      })

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

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

      Joi.validate({ id, organizationId, name, metadata }, validationRules.updateUser, function (err) {
        if (err) return cb(Boom.badRequest(err))

        const sqlQuery = SQL`
          UPDATE users
          SET name = ${name},
          metadata = ${metadata}
          WHERE id = ${id}
          AND org_id = ${organizationId}
        `
        db.query(sqlQuery, (err, result) => {
          if (utils.isUniqueViolationError(err)) return cb(Boom.conflict(err.detail))
          if (err) return cb(Boom.badImplementation(err))
          if (result.rowCount === 0) return cb(Boom.notFound(`User ${id} not found`))

          userOps.readUser({ id, organizationId }, cb)
        })
      })

      return promise
    }
function updateUser ( params , cb ) { let promise = null if ( typeof cb !== 'function' ) [ promise , cb ] = asyncify ( ) const { id , organizationId , name , metadata } = params Joi . validate ( { id , organizationId , name , metadata } , validationRules . updateUser , function ( err ) { if ( err ) return cb ( Boom . badRequest ( err ) ) const sqlQuery = SQL ` ${ name } ${ metadata } ${ id } ${ organizationId } ` db . query ( sqlQuery , ( err , result ) => { if ( utils . isUniqueViolationError ( err ) ) return cb ( Boom . conflict ( err . detail ) ) if ( err ) return cb ( Boom . badImplementation ( err ) ) if ( result . rowCount === 0 ) return cb ( Boom . notFound ( ` ${ id } ` ) ) userOps . readUser ( { id , organizationId } , cb ) } ) } ) return promise }
Update user details

@param  {Object}   params { id, organizationId, name, metadata } "metadata" can be null
@param  {Function} cb
Update user details