ansa
ansa3y ago

GenericId vs. Id

hi! what's the difference between Id and GenericId and how do I know which one to use? thanks!!
5 Replies
ian
ian3y ago
Great question! You should just use Id, which is a GenericId under the hood, but with types specific to your application.
ansa
ansaOP3y ago
so I should always be using Id? what's GenericId for?
ian
ian3y ago
yes. Using Id will give you autocomplete & type checking. You import it from convex/_generated/dataModel. GenericId is just the type that is used within the library code where your application types (e.g. table names, function definitions, schema, etc) aren't available
ansa
ansaOP3y ago
oh okay, got it!
ian
ian3y ago
We know it's confusing, since a lot of functions take a GenericId parameter, but we haven't figured out a way to make it more clear yet

Did you find this page helpful?