Charlie
09/15/2022, 8:29 PMAustin
09/26/2022, 8:38 PMShould I instead use Int instead for my DB ID’s?That’s really dependent on your application’s needs, but it’s very common to see both
Int
and String
used for database ID’s.
The typing issue comes when I’m trying to share types between backend and frontendThis is a common issue and a definite drawback when trying to reuse database types on the frontend. To assist with the actual implementation of the serialize/deserialize process, I’ve seen folks use packages like
superjson
which will handle BigInt
and Date
for you, but I’m not sure how it handles the TypeScript definitions. Most people derive new types based off the Prisma types or write utility types that convert non-serializable types into `string`s.Charlie
09/26/2022, 9:15 PM