"onConflictDoUpdate" fails with error in Array.flatMap

I am trying to run an upsert function, and update the values if it already exists. Now I might be completely in the wrong with the code.

I have made a base "repository" class that has the upsert function simplified as follows:

protected async upsert(
  data: typeof this.schema.$inferInsert | typeof this.schema.$inferInsert[]
){
  return await this.repository.insert(this.schema).values(data).onConflictDoUpdate({
    target: this.schema.id,
    set: data
  });
}


now I have tried the upsert in a loop for the array is the data happens to be an array, did not do anything, getting the same error.

 Cannot read properties of undefined (reading 'name')
    at file:///var/task/shared/modules/syncer/handlers/sync.mjs:729:921
    at Array.flatMap (<anonymous>)
    at UDe.buildUpdateSet (file:///var/task/shared/modules/syncer/handlers/sync.mjs:729:848)
    at QueryPromise.onConflictDoUpdate (file:///var/task/shared/modules/syncer/handlers/sync.mjs:723:85175)
    at $De.upsert (file:///var/task/shared/modules/syncer/handlers/sync.mjs:730:3003)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async $De.insertScan (file:///var/task/shared/modules/syncer/handlers/sync.mjs:730:6785)
Was this page helpful?