Skip to content

useConvexExplicitTableIds (JavaScript)

Language JavaScript (and super languages)
biome.json
{
"linter": {
"rules": {
"nursery": {
"useConvexExplicitTableIds": "error"
}
}
}
}

Require the table name as the first argument of Convex database calls.

Since convex 1.31.0, db.get(), db.patch(), db.replace(), and db.delete() accept the table name before the document ID. Passing it stops an ID with the wrong type from touching a document in another table, and Convex plans to deprecate calls without it.

const message = await ctx.db.get(messageId);
code-block.js:1:23 lint/nursery/useConvexExplicitTableIds ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ This db.get() call doesn't include the table name.

> 1 │ const message = await ctx.db.get(messageId);
│ ^^^^^^^^^^^^^^^^^^^^^
2 │

ℹ Without the table name, an ID with the wrong type can read or change a document in a different table than the one you expect. Convex also plans to deprecate calls without a table name.

ℹ Pass the name of the table as the first argument, for example db.get("messages", id).

ℹ 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 ctx.db.patch(messageId, { text: "updated" });
code-block.js:1:7 lint/nursery/useConvexExplicitTableIds ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ This db.patch() call doesn't include the table name.

> 1 │ await ctx.db.patch(messageId, { text: "updated" });
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

ℹ Without the table name, an ID with the wrong type can read or change a document in a different table than the one you expect. Convex also plans to deprecate calls without a table name.

ℹ Pass the name of the table as the first argument, for example db.patch("messages", id, value).

ℹ 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 ctx.db.replace(messageId, { text: "replaced", author: "Alice" });
code-block.js:1:7 lint/nursery/useConvexExplicitTableIds ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ This db.replace() call doesn't include the table name.

> 1 │ await ctx.db.replace(messageId, { text: "replaced", author: "Alice" });
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

ℹ Without the table name, an ID with the wrong type can read or change a document in a different table than the one you expect. Convex also plans to deprecate calls without a table name.

ℹ Pass the name of the table as the first argument, for example db.replace("messages", id, value).

ℹ 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 ctx.db.delete(messageId);
code-block.js:1:7 lint/nursery/useConvexExplicitTableIds ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ This db.delete() call doesn't include the table name.

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

ℹ Without the table name, an ID with the wrong type can read or change a document in a different table than the one you expect. Convex also plans to deprecate calls without a table name.

ℹ Pass the name of the table as the first argument, for example db.delete("messages", id).

ℹ 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.

const file = await ctx.db.system.get(storageId);
code-block.js:1:20 lint/nursery/useConvexExplicitTableIds ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ This db.system.get() call doesn't include the table name.

> 1 │ const file = await ctx.db.system.get(storageId);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

ℹ Without the table name, an ID with the wrong type can read or change a document in a different table than the one you expect. Convex also plans to deprecate calls without a table name.

ℹ Pass the name of the table as the first argument, for example db.system.get("_storage", id).

ℹ 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.

const message = await ctx.db.get("messages", messageId);
await ctx.db.patch("messages", messageId, { text: "updated" });
await ctx.db.replace("messages", messageId, { text: "replaced", author: "Alice" });
await ctx.db.delete("messages", messageId);
const file = await ctx.db.system.get("_storage", storageId);