Skip to content

Repository files navigation

TypeID Elixir

CIHex.pmDocumentation

A type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

TypeIDs are a modern, type-safe, globally unique identifier based on the upcoming UUIDv7 standard. They provide a ton of nice properties that make them a great choice as the primary identifiers for your data in a database, APIs, and distributed systems. Read more about TypeIDs in their spec.

Installation

The package can be installed from hex by adding typeid_elixir to your list of dependencies in mix.exs:

defdepsdo[{:typeid_elixir,"~> 1.0"}]end

Spec

The original TypeID spec is defined here.

Usage with Ecto

TypeID implements the Ecto.ParameterizedType behaviour so you can use TypeIDs as fields in your Ecto schemas.

defmoduleMyApp.Accounts.UserdouseEcto.Schema@primary_key{:id,TypeID,autogenerate: true,prefix: "acct",type: :uuid}@foreign_key_typeTypeID# ...end

Underlying types

TypeIDs can be stored as either :string or :uuid. :string will store the entire TypeID including the prefix. :uuid stores only the UUID portion and requires a :uuid or :uuid column.

Default type

The type used can be set globally in the application config.

config:typeid_elixir,default_type: :uuid

About

Elixir implementation of TypeIDs: type-safe, K-sortable, and globally unique identifiers inspired by Stripe IDs

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages