typeid
cuid2
typeid | cuid2 | |
---|---|---|
15 | 15 | |
2,762 | 2,135 | |
6.4% | 18.7% | |
8.2 | 4.1 | |
23 days ago | 3 months ago | |
Go | JavaScript | |
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.
cuid2
-
The UX of UUIDs
The CUID readme [1] explains that there's no real point to K-sortable on modern hardware:
[1] https://github.com/paralleldrive/cuid2?tab=readme-ov-file#no...
-
Bye Sequence, Hello UUIDv7
There's a comparison in the README of the project:
https://github.com/paralleldrive/cuid2#the-contenders
Some of the arguments mentioned are explained elsewhere in the README, others are assumed.
One argument standing out for me is the lack of collision-resistance for UUIDv4 which is surprising for me and I didn't spot any sources for that argument.
Another argument is the entropy source where they go about that Math.random is not reliable as a single entropy source but glimpsing at the source code, they sprinkle the CUID with Math.random data.
I am no expert in ID security, so I am not qualified to speak about the validity of their arguments, only that there's insufficient information to validate without prior knowledge about the problem domain.
-
You Don't Need UUID
I'm recently finding cuid2 to be the best of these alternative GUIDs. They seem to have all of the benefits for what you would want to use a GUID for, but none of the drawbacks of existing implementations.[1]
[1]: https://github.com/paralleldrive/cuid2#the-contenders
-
Cuid2 - Secure, collision-resistant ids optimized for horizontal scaling and performance. Next generation UUIDs.
I've just released v2.0.0 of my cuid2 python port. The original cuid2 package comes from JS world by ParallelDrive. They have a lot of the reasons to use Cuid2 posted in their repo, including
-
I "did my own research" and "AI" is not taking my job any time soon.
I recently wrote a Go implementation of CUID2 because I could not find an existing one. It is not hello-world, but it is not duff's device either, which by the way neither could explain what it did from just the raw code in isolation.
-
I'm making a hashing function to hash user ids for a hobby app and would love some feedback
I think this implementation is the original one. It has the following to say about why it exists. And what it is good for:
-
I've created long guide regard modern and old algorithms for Identifiers like ULID, UUID, slug and others.
There's also https://github.com/paralleldrive/cuid2 which likely should be added to this as it is likely one of the better ones out there now.
-
How to ensure that we get 100% unique id in postgres with node js and prisma
If you're using prisma then you can use CUID or CUID2 to manually generate it.
- Cuid2 – Secure, collision-resistant ids optimized for scaling and performance
- Cuid2: Next Generation GUIDs
What are some alternatives?
rust-ksuid - A pure-Rust KSUID implementation
pg_idkit - Postgres extension for generating UUIDs
typeid-ts - TypeID UUIDv7 implementation in Typescript (Lib and CLI)
postgresql-uuid-generate-v7
typeid-go - Go implementation of TypeIDs: type-safe, K-sortable, and globally unique identifiers inspired by Stripe IDs
ksuid - K-Sortable Globally Unique IDs
typeid-sql - SQL implementation 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
dxid - A better and safer way to display your primary keys in urls or in your app
snowid - A Decentralized, K-Ordered 128-bit Unique ID Generator library in C.
cuid2 - Next generation GUIDs. Collision-resistant ids optimized for horizontal scaling and performance.