DT
Drizzle Team•9mo ago
Mick

How to reuse values within update().set() ? How to increment int?

How may I reuse values from the current item within .update.set()? E.g. how can I do the following PostgreSQL query?
UPDATE totals
SET total = total + 1
WHERE name = 'bill';
UPDATE totals
SET total = total + 1
WHERE name = 'bill';
The docs has barely any informations about .update() 😦
2 Replies
Mick
MickOP•9mo ago
I found it in the "learn" page:
await db
.update(table)
.set({
counter: sql`${table.counter} - 1`,
})
.where(eq(table.id, 1));
await db
.update(table)
.set({
counter: sql`${table.counter} - 1`,
})
.where(eq(table.id, 1));
Mick
MickOP•9mo ago
The docs really need some reorganizing. Constantly cant find stuff. The "update" page is basically empty: https://orm.drizzle.team/docs/update
Drizzle ORM - Update
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Want results from more Discord servers?
Add your server