3 ms·
Why not just use auto-increment integers and expose them with something like this: https://www.npmjs.com/package/hashids https://www.npmjs.com/package/hashids (
by damethos 3y ago
Why not just use auto-increment integers and expose them with something like this: https://www.npmjs.com/package/hashids https://www.npmjs.com/package/hashids (The linked library is just an example). Yes, you will need to transform the IDs before returning them to an external caller which is a little bit annoying but it's probably not that a big of a deal.
Also another approach I've seen, which personally I find it a bit complicated, is to use auto-increment primary keys for the internal system and UUIDs for the public facing interactions.
- cryptos 3y agoIncrementing integers doesn't work well in a distributed system, where the IDs might be generated outside of the database (to have it before the transaction ends, for example).