Skip to content

noDrizzleUpdateWithoutWhere

biome.json
{
"linter": {
"rules": {
"nursery": {
"noDrizzleUpdateWithoutWhere": "error"
}
}
}
}

Require .where() to be called when using .update() with Drizzle ORM.

Without a .where() clause, an update statement will update all rows in the table. This rule requires explicitly calling .where() to prevent accidental mass updates.

Use the drizzleObjectName option to specify the variable names that represent Drizzle ORM instances.

biome.json
{
"linter": {
"rules": {
"nursery": {
"noDrizzleUpdateWithoutWhere": {
"options": {
"drizzleObjectName": [
"db"
]
}
}
}
}
}
}
await db.update(users).set({ name: "John" });
code-block.js:1:7 lint/nursery/noDrizzleUpdateWithoutWhere ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

.update() is used without .where(). This will update all rows in the table.

> 1 │ await db.update(users).set({ name: “John” });
^^^^^^^^^^^^^^^^
2 │

Add a .where() clause to update only the intended rows, or use .where(sql`1=1`) to explicitly update all rows.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

await db.update(users).set({ name: "John" }).where(eq(users.id, 1));