onConflict or upsert?

i have a table where email is a unique field. if im trying to insert into the table and the email is already being used i want to overwrite the other entry
3 Replies
Richard E
Richard E9mo ago
Drizzle ORM - Insert
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Richard E
Richard E9mo ago
Something like this I think:
await db.insert(your_table)
.values({ email: '[email protected]', name: 'Dan' })
.onConflictDoUpdate({ target: your_table.email, set: { name: 'John' } });
await db.insert(your_table)
.values({ email: '[email protected]', name: 'Dan' })
.onConflictDoUpdate({ target: your_table.email, set: { name: 'John' } });
Need_Not
Need_NotOP9mo ago
i swear i checked thanks
Want results from more Discord servers?
Add your server