-
We need to decide what the default id type is for our generated Prisma models (generated via Traditionally ids have been bigints. This is still the default for Rails today. However, uuids are much more common now with distributed systems because they have many advantages over incremented ids:
I think we should go with cuid for our default ids. This is already supported by Prisma. The only drawback, if you want to call it that, is that urls are more verbose. But not terribly so.
What do you all think? |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 6 replies
-
Personally much prefer We should also have docs around how to do slugged urls. |
Beta Was this translation helpful? Give feedback.
-
I agree that CUIDs/UUIDs are quite common nowadays and quite useful in bigger systems, BUTHonestly I don't think cuid/uuids should be the default since they'll mostly cause confusion and be harder to use in some cases.Regarding your points
-> Use authorization
-> This point is completely valid, but for some stuff like that you can just use slugs, or if you'd want UUID/CUID
-> Since we're still storing all of this in a single DB, this isn't really and issuee.g. in console
Also harder to find the next product from this URLS
|
Beta Was this translation helpful? Give feedback.
-
There are also drawbacks when it comes to database performance. UUIDs are slower to compare and take up more memory, so you can fit fewer of them on a page. |
Beta Was this translation helpful? Give feedback.
-
URLs, & therefore IDs, are a part of an app’s UX—if GitHub repositories were at /repositories/18474385 or if Slack channels were at /channels/general, they’d feel very different to use. I don’t have strong feelings one or another, but I’d love for this to be easy to customize per-app. |
Beta Was this translation helpful? Give feedback.
-
I'll put a vote in for integers. UUIDs being more common with distributed systems makes sense, but if under the hood we're using a regular database like Postgres then is it actually solving a problem? IDs are nicer, easier to reason with, and result in shorter URLs. I agree with @Zeko369 that doing authorization is a better approach than hoping a UUID won't be guessed. And I think needing to hide the number of records your app has is more of an outlier than something that should be addressed out of the box. What's the default generated by Prisma (I presume it's an integer ID) and are any of the arguments above really enough justification to change that default? |
Beta Was this translation helpful? Give feedback.
-
I started a discussion not so long ago about the differences between using either in the Prisma repo By the answer there I would say bigint should be the default and probably give the user the ability to change this in the config maybe? |
Beta Was this translation helpful? Give feedback.
-
I also think bigint should be the default
both can be solved using something like https://hashids.org/ |
Beta Was this translation helpful? Give feedback.
-
I think |
Beta Was this translation helpful? Give feedback.
-
I prefer incremental IDs as I find it easier to work with, query the database and test the app. Does Blitz allow for using slugs for URLs? Using slugs instead of random strings/ints in URLs is way better for SEO. |
Beta Was this translation helpful? Give feedback.
-
Ok, y'all have spoken! We'll stick with default integer IDs :) |
Beta Was this translation helpful? Give feedback.
Ok, y'all have spoken! We'll stick with default integer IDs :)