View Source AshDoubleEntry.ULID (ash_double_entry v1.0.6)

An Ash type for ULID strings.

Summary

Types

t()

A hex-encoded ULID string.

Functions

Casts a string to ULID.

Converts a binary ULID into a Crockford Base32 encoded string.

Converts a Crockford Base32 encoded ULID into a binary.

Generates a Crockford Base32 encoded ULID.

Generates a Crockford Base32 encoded ULID, guaranteed to sort equal to or after any other ULID generated for the same timestamp.

The underlying schema type.

Types

@type t() :: <<_::208>>

A hex-encoded ULID string.

Functions

Link to this function

bingenerate(timestamp \\ System.system_time(:millisecond))

View Source

Generates a binary ULID.

If a value is provided for timestamp, the generated ULID will be for the provided timestamp. Otherwise, a ULID will be generated for the current time.

Arguments:

  • timestamp: A Unix timestamp with millisecond precision.
Link to this function

bingenerate_last(timestamp \\ System.system_time(:millisecond))

View Source

Generates a binary ULID.

Do not use this for storage, only for generating comparators, i.e "balance as of a given ulid".

If a value is provided for timestamp, the generated ULID will be for the provided timestamp. Otherwise, a ULID will be generated for the current time.

Arguments:

  • timestamp: A Unix timestamp with millisecond precision.
Link to this function

cast_input(value, constraints)

View Source

Casts a string to ULID.

Converts a binary ULID into a Crockford Base32 encoded string.

Link to this function

dump_to_native(encoded, _)

View Source

Converts a Crockford Base32 encoded ULID into a binary.

Link to this function

generate(timestamp \\ System.system_time(:millisecond))

View Source

Generates a Crockford Base32 encoded ULID.

If a value is provided for timestamp, the generated ULID will be for the provided timestamp. Otherwise, a ULID will be generated for the current time.

Arguments:

  • timestamp: A Unix timestamp with millisecond precision.
Link to this function

generate_last(timestamp \\ System.system_time(:millisecond))

View Source

Generates a Crockford Base32 encoded ULID, guaranteed to sort equal to or after any other ULID generated for the same timestamp.

Do not use this for storage, only for generating comparators, i.e "balance as of a given ulid".

If a value is provided for timestamp, the generated ULID will be for the provided timestamp. Otherwise, a ULID will be generated for the current time.

Arguments:

  • timestamp: A Unix timestamp with millisecond precision.

The underlying schema type.