nursery/noConvexDuplicateIndexes
nursery · since 2.6.10
No autofixRecommended
biome.json
{
"linter": {
"rules": {
"nursery": {
"noConvexDuplicateIndexes": "error"
}
}
}
}Disallow Convex database indexes whose fields are the first fields of another index on the same table.
import { defineTable } from "convex/server";
import { v } from "convex/values";
defineTable({ author: v.string(), channel: v.string() })
.index("by_author", ["author"])
.index("by_author_and_channel", ["author", "channel"]);import { defineTable } from "convex/server";
import { v } from "convex/values";
defineTable({ author: v.string() })
.index("by_author", ["author"])
.index("by_writer", ["author"]);import { defineTable } from "convex/server";
import { v } from "convex/values";
// Neither index starts with all the fields of the other one.
defineTable({ author: v.string(), channel: v.string() })
.index("by_channel", ["channel"])
.index("by_author_and_channel", ["author", "channel"]);
// The longer index is staged, so the shorter one is still needed until it's ready.
defineTable({ author: v.string(), channel: v.string() })
.index("by_author", ["author"])
.index("by_author_and_channel", { fields: ["author", "channel"], staged: true });
// To query by `author` alone, use the longer index and filter only on its first field.
await ctx.db
.query("messages")
.withIndex("by_author_and_channel", (q) => q.eq("author", author))
.collect();Examples from the Biome documentation.
ESLint does not have this rule.
Oxlint does not have this rule.
nursery/noConvexDuplicateIndexes
nursery · since 2.6.10
{
"linter": {
"rules": {
"nursery": {
"noConvexDuplicateIndexes": "error"
}
}
}
}Require the object syntax when registering Convex queries, mutations, and actions.
Disallow ineffective ordering in files.includes patterns.
Disallow the use of Astro's set:html directive.
Disallow calling .filter() on a Convex database query.