2 ms·
It would be great to have a quick primer on why this is better than what people typically homebrew, like base62 encoding a random number.
by Schnitz 3y ago
It would be great to have a quick primer on why this is better than what people typically homebrew, like base62 encoding a random number.
- sneak 3y agoDatabase PKs usually aren’t random, which AFAIK is what is usually used as the number in this case.
- hot_gril 3y agoDatabase PK really shouldn't be exposed like this. I think that's what they're getting at, though. The thing is, sequential database PK is still shorter and more readable than a Sqid.
- 8organicbits 3y agoIf you use a random number then you need to store it somewhere to map back to the original. Sqids is an encoding, you can decode the sqid back to the original without storage overhead. Features like the profanity filter avoid creating URL routes like /user/cuntFh. Cross language support allows interop between the encoder and decoder across microservices written in different languages.
- antifa 3y agobase62 decodes back to Int32 perfectly.