I had built a query in Knex.js to insert records to the DB
upsert(input) {
if (isEmpty(input)) return Promise.resolve(0);
return this.tx(tableName)
.insert(input.map(prepareInput))
.onConflict([columns.candidateId, columns.startAt])
.merge()
.returning()
.then(({ rowCount }) => rowCount);
}
But I'm getting this error
ON CONFLICT DO UPDATE command cannot affect row a second time
I need to insert data and merge it with the existing one and not sure how should I edit this query to avoid the error