packages/udaru-core/lib/ops/userOps.js
function insertUser (client, { id, name, organizationId, metadata }, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      id = id || uuidV4()

      const sqlQuery = SQL`
        INSERT INTO users (
          id, name, org_id, metadata
        ) VALUES (
          ${id}, ${name}, ${organizationId}, ${metadata}
        )
        RETURNING id
      `

      client.query(sqlQuery, (err, result) => {
        if (utils.isUniqueViolationError(err)) return cb(Boom.conflict(err.detail))
        if (err) return cb(Boom.badImplementation(err))

        cb(null, result)
      })

      return promise
    }
function insertUser (client, { id, name, organizationId, metadata }, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      id = id || uuidV4()

      const sqlQuery = SQL`
        INSERT INTO users (
          id, name, org_id, metadata
        ) VALUES (
          ${id}, ${name}, ${organizationId}, ${metadata}
        )
        RETURNING id
      `

      client.query(sqlQuery, (err, result) => {
        if (utils.isUniqueViolationError(err)) return cb(Boom.conflict(err.detail))
        if (err) return cb(Boom.badImplementation(err))

        cb(null, result)
      })

      return promise
    }
function insertUser ( client , { id , name , organizationId , metadata } , cb ) { let promise = null if ( typeof cb !== 'function' ) [ promise , cb ] = asyncify ( ) id = id || uuidV4 ( ) const sqlQuery = SQL ` ${ id } ${ name } ${ organizationId } ${ metadata } ` client . query ( sqlQuery , ( err , result ) => { if ( utils . isUniqueViolationError ( err ) ) return cb ( Boom . conflict ( err . detail ) ) if ( err ) return cb ( Boom . badImplementation ( err ) ) cb ( null , result ) } ) return promise }
Insert a new user into the database

@param  {Object}      client
@param  {String|null} options.id
@param  {String}      options.name
@param  {String}      options.organizationId
@param  {String}      options.metadata (optional)
@param  {Function}    cb
Insert a new user into the database