Elixir implementation of TypeIDs: type-safe, K-sortable, and globally unique identifiers inspired by Stripe IDs
Find a file
Sloane 4930e7115c
Common protocol implementations (#16)
* `String.Chars` impl

* `Phoenix.HTML.Safe` impl

* `Phoenix.Param` impl
2023-07-07 13:26:25 -04:00
.github add publish workflow (#13) 2023-07-06 16:35:30 -04:00
lib Common protocol implementations (#16) 2023-07-07 13:26:25 -04:00
priv/spec add script to update spec, update spec files 2023-07-06 10:22:31 -04:00
scripts add script to update spec, update spec files 2023-07-06 10:22:31 -04:00
test Common protocol implementations (#16) 2023-07-07 13:26:25 -04:00
.formatter.exs mix new 2023-06-29 15:20:23 -04:00
.gitignore mix new 2023-06-29 15:20:23 -04:00
.tool-versions mix new 2023-06-29 15:20:23 -04:00
CHANGELOG.md Common protocol implementations (#16) 2023-07-07 13:26:25 -04:00
CODE_OF_CONDUCT.md Add Code of Conduct and Contributing documentation (#11) 2023-07-06 15:59:55 -04:00
CONTRIBUTING.md Add Code of Conduct and Contributing documentation (#11) 2023-07-06 15:59:55 -04:00
LICENSE add license 2023-06-30 06:49:44 -04:00
mix.exs Common protocol implementations (#16) 2023-07-07 13:26:25 -04:00
mix.lock Common protocol implementations (#16) 2023-07-07 13:26:25 -04:00
README.md Common protocol implementations (#16) 2023-07-07 13:26:25 -04:00

TypeID Elixir

CI

Read the full documentation on hexdocs

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:

def deps do
  [
    {:typeid_elixir, "~> 0.3.1"}
  ]
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.

defmodule MyApp.Accounts.User do
  use Ecto.Schema

  @primary_key {:id, TypeID, autogenerate: true, prefix: "acct", type: :binary_id}

  # ...
end