Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

132
Vistas
Knex Insert and onConflict is not a function

I tried to add a simple upsert using knex. And the recommended way is (for postgres) to use onConflict. The original code that works (except for the updating part):

const dbObject = db();
await dbObject('names')
  .insert({key: key, name: name});

So I updated it according to what I see in the manual:

enter image description here

const dbObject = db();
await dbObject('names')
  .insert({key: key, name: name})
  .onConflict('key')
  .merge();

However, this gave the following error:

TypeError: dbObject(...).insert(...).onConflict is not a function

Which to me is quite a mystery, since I am using the correct version:

npm view knex version

0.95.0

And the knex db object is created basically by (config is loaded from a file):

const knex = knexBuilder({
  client: 'pg',
  connection: config,
  pool: {min: 0, max: maxConnections},
});
return knex

What is causing the error, how is onConflict not a function?

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda