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
RE
Richard E41d ago
Drizzle ORM - Insert
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
RE
Richard E41d ago
Something like this I think:
await db.insert(your_table)
.values({ email: 'a@b.com', name: 'Dan' })
.onConflictDoUpdate({ target: your_table.email, set: { name: 'John' } });
await db.insert(your_table)
.values({ email: 'a@b.com', name: 'Dan' })
.onConflictDoUpdate({ target: your_table.email, set: { name: 'John' } });
N
Need_Not41d ago
i swear i checked thanks
Want results from more Discord servers?
Add your server
More Posts