3 ms·
Don't expose your internal IDs, expose some identifier specifically made to be exposed.
by danbruc 4y ago
Don't expose your internal IDs, expose some identifier specifically made to be exposed.
- davidcelis 4y agoThe post covers this: > Our API is a Ruby on Rails application. For all public-facing models, we have added a `public_id` column to our database. We still use standard auto-incrementing BigInts for our primary key. The `public_id` is only used as an external identifier.
- s4i 4y agoI assume you mean internal IDs == primary keys in your database. If that's the case, and if your primary keys are UUIDv4's, ULIDs, KSUIDs, Cuids or similar... then why not? There are a lot of benefits, such as simpler SQL queries in your backend. You can also merge data from different databases into one as collissions are highly unlikely, which is not possible with numeric IDs.