typeid
ksuid
typeid | ksuid | |
---|---|---|
15 | 38 | |
2,762 | 4,702 | |
6.4% | 1.2% | |
8.2 | 3.1 | |
23 days ago | 7 months ago | |
Go | Go | |
Apache License 2.0 | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
typeid
-
ULIDs and Primary Keys
I’ve seen this sort of design referred to as “typed IDs”: https://github.com/jetify-com/typeid
Doesn’t use the crockford encoding, but does is another one that minimises confusables.
- Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs
-
The UX of UUIDs
https://github.com/uuid6/new-uuid-encoding-techniques-ietf-d...
But there is always TypeID in the meantime which uses UUIDv7 under the hood: https://github.com/jetify-com/typeid
Either way, I am in favor of prefixing and using alternative encodings, but it will need some time to figure out the best route. In the mean time, there are so many alternatives. TypeID, NanoID, ULID, etc. I even made my own quick one just for giggles: https://github.com/daegalus/snowflakes
-
Adding type safety to object IDs in TypeScript
If you want a type-prefixed UUIDv7 type, I can wholeheartedly recommend TypeID-JS: https://github.com/jetpack-io/typeid-js
Also available for a whole bunch of other languages: https://github.com/jetpack-io/typeid
UUIDv7 is UUIDv4-compatible (i.e. you can put a v7 UUID anywhere a v4 UUID would go, like in Postgres's UUID datatype) and is time-series sortable, so you don't lose that nice lil' benefit of auto-incrementing IDs.
And if you use something like TypeORM to define your entities, you can use a Transformer to save as plain UUIDv7 in the DB (so you can use UUID datatypes, not strings), but deal with them as type-prefixed strings everywhere else:
```
-
You Don't Need UUID
IMO, a good middleground is using schemes like TypeID[0], ulid[1], or KSUID[2] that provides a more compact and readable (base32) representation and provides better database locality (K-sortable).
[0] https://github.com/jetpack-io/typeid
- typeid: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs
-
Why do so many EF tutorials use GUIDs as primary key?
If you do consider a GUID, I recommend the TypeID library we recently open-sourced. It has typing as part of the id, and it's based on UUIDv7. We think it has a few benefits over other GUIDs, including: + Easier to debug because of the type information + Type-safety can be enforced + Thanks to UUIDv7 is has good locality properties when used as the primary key of a database (unlike a completely random GUID) + We have a dotnet implementation in C# available
-
How to create unique id for every todo in a todo list.
If you’re open to a globally unique identifier like UUID, I’d recommend you check out TypeIDs which we recently open sourced https://github.com/jetpack-io/typeid. They are based on the UUIDv7 standard, but add type information (like what Stripe does in their APIs), and we have a TypeScript implementation available.
ksuid
- What happens after 100 years?
-
Zero Downtime Postgres Upgrades
OP here - we avoid sequences in all but one part of our application due to a dependency. We use [KSUIDs][1] and UUID v4 in various places. This one "gotcha" applies to any sequence, so it's worth calling out as general advice when running a migration like this.
[1]: https://segment.com/blog/a-brief-history-of-the-uuid/
-
Bye Sequence, Hello UUIDv7
UUID v4 isn't large enough to prevent collisions, that is why segment.io created https://github.com/segmentio/ksuid which is 160bit vs the 128bit of a UUIDv4.
- You Don't Need UUID
- A Brief History of the UUID
-
Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs
Assuming you don't need to use UUIDv7 (or any UUID's) then https://github.com/segmentio/ksuid provides a much bigger keyspace. You could just append a string prefix if you wanted to namespace, but the chance of collisions of a KSUID is many times smaller than a UUID of any version.
-
Unexpected downsides of UUID keys in PostgreSQL
KSUID's are have temporal-lexicographical order plus 128 bits of entropy, which is more than UUIDv4.
https://github.com/segmentio/ksuid
-
UUIDs are so much better than autoincrementing ids and it's not even close
That's why you use ksuid (https://segment.com/blog/a-brief-history-of-the-uuid/) or, if you're willing to go with a draft spec you could go with the new UUID formats https://www.ietf.org/archive/id/draft-ietf-uuidrev-rfc4122bi...
-
What Happened to UUIDv2?
Interesting in more history of UUIDs? Twilio Segment's blog has an amazing history lesson about how they came to be.
-
Which UUID package do you use? and why?
I use the ksuid from segment. https://github.com/segmentio/ksuid
What are some alternatives?
rust-ksuid - A pure-Rust KSUID implementation
ulid - Universally Unique Lexicographically Sortable Identifier (ULID) in Python 3
typeid-ts - TypeID UUIDv7 implementation in Typescript (Lib and CLI)
pg-ulid - ULID Functions for PostgreSQL
typeid-go - Go implementation of TypeIDs: type-safe, K-sortable, and globally unique identifiers inspired by Stripe IDs
nanoid - A tiny (124 bytes), secure, URL-friendly, unique string ID generator for JavaScript
typeid-sql - SQL implementation TypeIDs: type-safe, K-sortable, and globally unique identifiers inspired by Stripe IDs
ulid-mssql - Implementation of ULID generator For Microsoft SQL Server
snowid - A Decentralized, K-Ordered 128-bit Unique ID Generator library in C.
python-ksuid - A pure-Python KSUID implementation
launchpad - From Code to Kubernetes in One Step.
uuid7 - UUID version 7, which are time-sortable (following the Peabody RFC4122 draft)