Replace on Insert

ZZen5/7/2023
I can see that there is a .ignore() option added to insert, but is there an equivalent .replace() or someway to flag it in the code?

I'm doing an insert many by passing through an array of values (e.g. await db.insert(ActivityTable).values(values);) which is effectively an over write of existing data as well as new data
Mmachour5/7/2023
Still discovering Drizzle, but I think you're looking for onConflictDoUpdate() to make an upsert
ZZen5/7/2023
Sorry I wasn't clear - I'm using mysql-core which doesn't have the onConflictDoUpdate chain
ZZen5/7/2023
though I'm again reminded how postgres is the superior database!
Mmachour5/7/2023
just discovered that all drivers don't implement all methods 😅
Mmachour5/7/2023
well, using MySQL that would be a REPLACE INTO ..
Mmachour5/7/2023
I see a onDuplicateKeyUpdate for MySQL tho
ZZen5/7/2023
yup the REPLACE is what I'm used to using in SQL. I've never used ON DUPLICATE KEY UPDATE in SQL before, I'll check it out now - hopefully that's what I need!
ZZen5/9/2023
for reference onDuplicateKeyUpdate worked! My final code looked something like this:

db.insert(TestingTable)
  .values(values)
  .onDuplicateKeyUpdate({
    set: {
      fizz: sql`values(fizz)`,
      buzz: sql`values(buzz)`,
      fizzBuzz: sql`values(fuzz_buzz)`,
      updatedAt: sql`values(updated_at)`,
    },
  });