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•2y 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•2y 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•2y ago
Thank you

Did you find this page helpful?