Перейти до вмісту

noDrizzleDeleteWithoutWhere

Цей контент ще не доступний вашою мовою.

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

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

Without a .where() clause, a delete statement will delete all rows from the table. This rule requires explicitly calling .where() to prevent accidental data loss.

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

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

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

> 1 │ await db.delete(users);
^^^^^^^^^^^^^^^^
2 │

Add a .where() clause to delete only the intended rows, or use .where(sql`1=1`) to explicitly delete 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.delete(users).where(eq(users.id, 1));