David Alonso
David Alonso9mo ago

__tableName is undefined

Hey, I have a component that takes in an id: Id<"blocks"> | Id<"tables">; and I want to have a quick way to check the type of id. Currently I was doing: const isPageItem = id && id.__tableName === "blocks"; but __tableName seems to be undefined. What should I do?
2 Replies
sshader
sshader9mo ago
Per https://docs.convex.dev/api/modules/values#genericid, IDs are strings at runtime and __tableName only exists during TypeScript compilation. Check out https://discord.com/channels/1019350475847499849/1251451648077987901/1251510531009810472
Module: values | Convex Developer Hub
Utilities for working with values stored in Convex.
David Alonso
David AlonsoOP9mo ago
Asked some questions in that thread

Did you find this page helpful?