Become a Gold Sponsor
Drizzle | SQL Toggle value
PostgreSQL
MySQL
SQLite
This guide assumes familiarity with:

To toggle a column value you can use update().set() method like below:

import { eq, not } from 'drizzle-orm';

const db = drizzle(...);

await db
  .update(table)
  .set({
    isActive: not(table.isActive),
  })
  .where(eq(table.id, 1));
update "table" set "is_active" = not "is_active" where "id" = 1;

Please note that there is no boolean type in MySQL and SQLite. MySQL uses tinyint(1). SQLite uses integers 0 (false) and 1 (true).