typeid
Allows to use TypeIDs in Postgres natively
Repository
blitss/typeid-postgres
https://github.com/blitss/typeid-postgres
Source
typeid-postgres-0.3.0.tar.gz
typeid-postgres-0.3.0.tar.gz
Overview
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 4580 | typeid | No | Yes | No | Yes | No | No | - |
| Related | pg_uuidv7 sequential_uuids pg_idkit pgx_ulid snowflake pg_uuid_v8 uuid-ossp pg_hashids pg_slug_gen base36 |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.3.0 | 1817161514 | pg_typeid | - |
| RPM | PIGSTY | 0.3.0 | 1817161514 | pg_typeid_$v | - |
| DEB | PIGSTY | 0.3.0 | 1817161514 | postgresql-$v-typeid | - |
Build
You can build the RPM / DEB packages for pg_typeid using pig build:
Install
You can install pg_typeid directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Install
pig
dnf
apt
Create Extension:
Usage
typeid: TypeID support for PostgreSQL - type-safe, sortable UUIDs with a prefix
TypeID is an extension of UUIDv7 with a type prefix, stored internally as a prefix + binary UUID.
Functions
| Function | Return Type | Description |
|---|---|---|
typeid_generate(prefix TEXT) | typeid | Generate a new TypeID with the given prefix |
typeid_generate_nil() | typeid | Generate a TypeID with an empty prefix |
typeid_is_valid(input TEXT) | BOOLEAN | Check if a TypeID string is valid |
typeid_prefix(typeid) | TEXT | Extract the prefix from a TypeID |
typeid_to_uuid(typeid) | UUID | Convert a TypeID to a UUID |
uuid_to_typeid(prefix TEXT, uuid UUID) | typeid | Convert a UUID to a TypeID |
typeid_uuid_generate_v7() | UUID | Generate a UUID v7 |
typeid_has_prefix(typeid, prefix TEXT) | BOOLEAN | Check if a TypeID has a specific prefix |
typeid_is_nil_prefix(typeid) | BOOLEAN | Check if a TypeID has a nil prefix |
typeid_generate_batch(prefix TEXT, count INTEGER) | SETOF typeid | Generate a batch of TypeIDs |
Operators
<,<=,=,>=,>,<>for comparing TypeIDs@>for checking if a TypeID has a certain prefix (e.g.id @> 'user')- B-tree operator class for indexing
Examples
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)