Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

390
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!