UXID (UXID v2.1.0)
View SourceGenerates UXIDs and acts as an Ecto ParameterizedType
User eXperience focused IDentifiers (UXIDs) are identifiers which:
- Describe the resource (aid in debugging and investigation)
- Work well with copy and paste (double clicking selects the entire ID)
- Can be shortened for low cardinality resources
- Are secure against enumeration attacks
- Can be generated by application code (not tied to the datastore)
- Are K-sortable (lexicographically sortable by time - works well with datastore indexing)
- Do not require any coordination (human or automated) at startup, or generation
- Are very unlikely to collide (more likely with less randomness)
- Are easily and accurately transmitted to another human using a telephone
Many of the concepts of Stripe IDs have been used in this library.
Summary
Functions
Generates a loaded version of the UXID.
Casts the given input to the UXID ParameterizedType with the given parameters.
Dumps the given term into an Ecto native type.
Dictates how the type should be treated if embedded. For UXIDs, we use :self since they're already strings.
Checks if two UXIDs are equal.
Returns an encoded UXID string along with response status.
Returns an unwrapped encoded UXID string.
Converts the options specified in the field macro into parameters to be used in other callbacks.
Loads the given term into a UXID.
Returns a new UXID.Codec struct. This is useful for development.
Returns the underlying schema type for a UXID.
Types
Functions
Generates a loaded version of the UXID.
Casts the given input to the UXID ParameterizedType with the given parameters.
Dumps the given term into an Ecto native type.
Dictates how the type should be treated if embedded. For UXIDs, we use :self since they're already strings.
Checks if two UXIDs are equal.
Returns an encoded UXID string along with response status.
Returns an unwrapped encoded UXID string.
Converts the options specified in the field macro into parameters to be used in other callbacks.
Loads the given term into a UXID.
@spec new(opts :: options()) :: {:ok, UXID.Codec.t()}
Returns a new UXID.Codec struct. This is useful for development.
Returns the underlying schema type for a UXID.