Drizzle | SQL 切换值
PostgreSQL
MySQL
SQLite
This guide assumes familiarity with:
要切换列值,可以使用 update().set()
方法,如下所示:
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;
请注意,MySQL 和 SQLite 中没有布尔类型。 MySQL 使用 tinyint(1)。 SQLite 使用整数 0(false)和 1(true)。