类型安全、可排序、全局唯一标识符,灵感来自 Stripe ID
TypeIDs are a modern, type-safe extension of UUIDv7. Inspired by a similar use of prefixes in Stripe's APIs.
TypeIDs are canonically encoded as lowercase strings consisting of three parts:
Here's an example of a TypeID of type user:
user_2x4y6z8a0b1c2d3e4f5g6h7j8k
└──┘ └────────────────────────┘
type uuid suffix (base32)
A formal specification defines the encoding in more detail.
You can try converting UUID to TypeID and back using Jetify's TypeID Converter.
Paste your TypeID string to convert to UUID or put your prefix and UUID in this
format: prefix:UUID to convert to TypeID.
user ID where a post ID is
expected. When debugging, you can immediately understand what type of entity a
TypeID refers to thanks to the type prefix.Implementations should adhere to the formal specification.
Latest spec version: v0.3.0
jetify| Language | Status | Spec Version |
|---|---|---|
| Go | ✓ Implemented | v0.3 |
| SQL | ✓ Implemented | v0.2 |
| TypeScript | ✓ Implemented | v0.3 |
We are looking for community contributions to implement TypeIDs in other languages.
This repo includes a command-line tool for generating TypeIDs. To install it, run:
curl -fsSL https://get.jetify.com/typeid | bash
To generate a new TypeID, run:
$ typeid new prefix
prefix_01h2xcejqtf2nbrexx3vqjhp41
To decode an existing TypeID into a UUID run:
$ typeid decode prefix_01h2xcejqtf2nbrexx3vqjhp41
type: prefix
uuid: 0188bac7-4afa-78aa-bc3b-bd1eef28d881
And to encode an existing UUID into a TypeID run:
$ typeid encode prefix 0188bac7-4afa-78aa-bc3b-bd1eef28d881
prefix_01h2xcejqtf2nbrexx3vqjhp41
Alternatives to UUIDv7 that are also worth considering (but not type-safe like TypeIDs):
暂无开放 Issues,或尚未同步最近议题。