DT
Drizzle Team•16mo ago
xamarot

Invert a boolean easily?

In SQL you can do
UPDATE my_table SET is_active = NOT is_active;
UPDATE my_table SET is_active = NOT is_active;
Is there a similiar syntax for Drizzle?
3 Replies
Aidan Laycock
Aidan Laycock•16mo ago
You could just use the SQL operator here. (https://orm.drizzle.team/docs/sql) 🙂 That'd be the easiest way to handle this
Angelelz
Angelelz•16mo ago
This might be the way to go:
const query = await db.update(my_table).set({is_active: sql` NOT is_active`}).where(...)
const query = await db.update(my_table).set({is_active: sql` NOT is_active`}).where(...)
I'm doing this from memory so you might need to do some tests...
xamarot
xamarotOP•16mo ago
Thank you
Want results from more Discord servers?
Add your server