GenericId vs. Id
hi! what's the difference between Id and GenericId and how do I know which one to use? thanks!!
5 Replies
Great question! You should just use
Id
, which is a GenericId
under the hood, but with types specific to your application.so I should always be using Id? what's GenericId for?
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 availableoh okay, got it!
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