import Knex from "knex"; const knex = Knex({ client: 'pg', connection: process.env.DATABASE_URL, }); const records = [ { id: 2, login: "admin" }, ]; async function upsert() { const result = await knex.raw( `? ON CONFLICT (id) DO UPDATE SET login = EXCLUDED.login, updated_at = CURRENT_TIMESTAMP RETURNING *;`, [knex("users").insert(records)], ); }