title: "syntax error at or near \"SET\"" when creating a user using node with Postgresql
body: <p>I'm trying to translate my old mysql app to Postgresql, it was very difficult to connect to the server, but when i think it worked, this message appears on insomnia.
  <a href="https://i.stack.imgur.com/F75Pg.png" rel="nofollow noreferrer">The message</a>
  I tried using different methods that i found on Google but they didn't work for me.
  I think that the problem is how i'm connecting to the server.
  I'm new using postgresql.</p>
  
  <pre><code>const { Pool, Client } = require("pg")
  
  const config = require("../config")
  
  const connection = new Pool({
    host: config.postgresql.host,
    user: config.postgresql.user,
    password: config.postgresql.password,
    database: config.postgresql.database,
    port: "5432",
    ssl: true
  })
  
  function list(table) {
    return new Promise((resolve, reject) =&gt; {
      connection.query(`SELECT * FROM ${table}`, (err, data) =&gt; {
        if (err) return reject(err)
        resolve(data)
      })
    })
  }
  
  function get(table, id) {
    return new Promise((resolve, reject) =&gt; {
      connection.query(`SELECT * FROM ${table} WHERE id=${id}`, (err, data) =&gt; {
        if (err) return reject(err)
        resolve(data)
      })
    })
  }
  
  function insert(table, data) {
    return new Promise((resolve, reject) =&gt; {
      connection.query(`INSERT INTO ${table} SET ${data}`, (err, result) =&gt; {
        if (err) return reject(err)
        resolve(result)
      })
    })
  }
  
  function update(table, data) {
    return new Promise((resolve, reject) =&gt; {
      connection.query(
        `UPDATE ${table} SET ${data} WHERE id=${data.id}`,
        (err, result) =&gt; {
          if (err) return reject(err)
          resolve(result)
        }
      )
    })
  }
  
  const upsert = async (table, payload) =&gt;
    new Promise((resolve, reject) =&gt; {
      connection.query(
        `INSERT INTO ${table} SET ${payload} ON DUPLICATE KEY UPDATE ${payload}`,
        (error, data) =&gt; {
          console.log("UPDATE DATA: ", data)
          if (error) {
            return reject(error)
          }
          resolve(data)
        }
      )
    })
  
  function query(table, query, join) {
    let joinQuery = ""
    if (join) {
      const key = Object.keys(join)[0]
      const val = join[key]
      joinQuery = `JOIN ${key} ON ${table}.${val} = ${key}.id`
    }
  
    return new Promise((resolve, reject) =&gt; {
      connection.query(
        `SELECT * FROM ${table} ${joinQuery} WHERE ${table}.${query}`,
        (err, res) =&gt; {
          if (err) return reject(err)
          resolve(res[0] || null)
        }
      )
    })
  }
  
  module.exports = {
    list,
    get,
    upsert,
    query
  }
  </code></pre>