Knex Insert and onConflict is not a function

Viewed 2333

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?

0 Answers
Related