God, Love, News, Event, Entertainment, Amebo,..... All about Bringing out the best in you...
Show HN: UPID – a unique ID with built-in prefix https://ift.tt/AsePjR0
Show HN: UPID – a unique ID with built-in prefix The discussion about what to use for database keys has come up a few times on HN. Integers or UUID, or maybe ULID/UUIDv7 with a time component. One that also comes up is prefixes (as used by Stripe, most famously). The biggest downside (imo) of the Stripe approach is that you either have to store them as strings, which isn't great, or strip/prepend in your API layer. So I made a new thing called UPID. It's most similar to ULID, as it includes a time-component (but with lower precision) and also encodes to a base32 alphabet. But it also includes a 20-bit prefix (allowing four characters). So it can be stored as a UUID or anywhere a 128-bit blob goes, and it always knows what its prefix is because it's baked in. I've made implementations for Python, Rust and TypeScript, as well as a Postgres extension (with a upid datatype). Mentioned it a few weeks ago in a HN discussion and people seemed pretty interested so thought I'd post it as a submission. In Rust it looks like this: use upid::Upid; Upid::new("post"); // post_2acqyme2ygscyguveuhj5a There are more examples in the repositories. Repo (Python, Rust, Postgres): https://ift.tt/MOewWbJ TypeScript: https://ift.tt/DoIq40M Demo site: https://upid.rdrn.me/ https://ift.tt/MOewWbJ August 20, 2024 at 12:31AM
Subscribe to:
Post Comments (Atom)
Show HN: phx.tools – The complete development environment for Elixir and Phoenix https://ift.tt/DTpdrOm
Show HN: phx.tools – The complete development environment for Elixir and Phoenix https://phx.tools September 21, 2024 at 12:17AM
-
HOMILY FOR FRIDAY, 14TH JUNE, 2024 TENTH WEEK IN ORDINARY TIME 1KING 19:9a. 11-16; GOSPEL: MATT 5:27-32 The conscience of man is where moral...
-
HOMILY FOR TUESDAY, 11TH WEEK IN ORDINARY TIME 1Kings 21:17-29; Matt 5:43-48 The last phrase of the gospel passage says “Be perfect just a...
-
HOMILY FOR MONDAY 24TH WEEK IN ORDINARY TIME B {1COR 12:12-14.27-31a; LUKE 7:11-17} Faith without good works is indeed dead. This theme co...
No comments:
Post a Comment