David Alonso
David Alonso9mo ago

Table helper name ambiguity

If I have a Table defined like so:
export const TableViews = Table("tableViews", tableViewsFields).table.index(
"byCollectionId",
["collectionId"]
);
const fireviewSchema = defineSchema(
{
tableViewd: TableViews,

},
}
export const TableViews = Table("tableViews", tableViewsFields).table.index(
"byCollectionId",
["collectionId"]
);
const fireviewSchema = defineSchema(
{
tableViewd: TableViews,

},
}
I can see that convex creates a new table called tableViewd in the dashboard, so not sure what the "tableViews" string is being used for? @ian
1 Reply
ian
ian9mo ago
You can click into the code to see - it affects the _id validator and types returned. So e.g. if you use the TableViews.doc validator it'll both expect a type of Id<'tableViews'> and at runtime it'll check that the _id is an ID in a "tableViews" table. If you don't use ._id, .withSystemFields, .doc, or .systemFields then it doesn't affect anything here you're immediately using .table so it's equivalent to defineTable(tableViewsFields).index...

Did you find this page helpful?