How to do "onConflictDoUpdate" when inserting an array of values?

I want to add multiple rows to my table but it has a unique key, so it has to update the row if there is a conflict. How do I do this with the ORM?

await db
  .insert(items)
  .values(
    chunk.map((item) => ({
      auctionHouseId: Number(auctionHouseId),
      itemId: item.itemId,
      // ...
    })),
  )
  .onConflictDoUpdate({
    target: [items.itemId, items.auctionHouseId],
    set: {
      // What do I put in here? This is outside of the `map` context
    },
  });
Was this page helpful?