1 unstable release
| 0.1.0 | Apr 15, 2023 |
|---|
#426 in Database implementations
9KB
197 lines
oid
An id scheme. Why another one?
lexicographically sortable-uuidv4is not sorted and will explode database indexes. Likeulid,oidis lexicographically sortable.- named - oid can be prefixed with a name, like
team_0da0fa0e02cssbhkanf04c_srb0 - short-codable - oid can be written in shortform like
team_srb0 - double-click-copyable - try double clicking this uuid:
a827f03c-f5b0-40ef-8d53-3fb3cdf4e055. Then try thisoid:team_0da0fa0e02cssbhkanf04c_srb0
Usage
label!(Team, "team");
label!(User, "usr");
label!(Transaction, "tx");
fn main() {
let id = Team::oid();
// e.g. id: team_0da0fa0e02cssbhkanf04c_srb0
println!("id: {}", id);
// e.g. id: team_srb0
// e.g. uuid: a827f03c-f5b0-40ef-8d53-3fb3cdf4e055
println!("short: {}", id.short());
println!("uuid: {}", id.uuid());
// We didn't use a Label, so it's simply missing.
let id = new_oid();
// e.g. id: 0da0fa0e02cssbhkanf04c_srb0
println!("id: {}", id);
}
Roadmap
- Create a postgres extension to store oids as u128, but have it display in human readable form.
Dependencies
~1–17MB
~173K SLoC