Needle.ULID (needle_ulid v0.3.0) View Source

An Ecto type for ULID strings.

Link to this section Summary

Functions

Casts a 26-byte encoded string to ULID or a 16-byte binary unchanged

Same as cast/1 but raises Ecto.CastError on invalid arguments.

Converts a Crockford Base32 encoded ULID into a binary.

Callback implementation for Ecto.Type.embed_as/1.

Returns the randomness portion of the encoded ulid

Returns the timestamp portion of the encoded ulid

Callback implementation for Ecto.Type.equal?/2.

Generates a Crockford Base32 encoded ULID.

Converts a binary ULID into a Crockford Base32 encoded string.

translates alphanumerics into a sentinel ulid value

Returns the timestamp of an encoded or unencoded ULID

The underlying schema type.

Link to this section 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.

Casts a 26-byte encoded string to ULID or a 16-byte binary unchanged

Same as cast/1 but raises Ecto.CastError on invalid arguments.

Converts a Crockford Base32 encoded ULID into a binary.

Callback implementation for Ecto.Type.embed_as/1.

Returns the randomness portion of the encoded ulid

Returns the timestamp portion of the encoded ulid

Callback implementation for Ecto.Type.equal?/2.

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.

Converts a binary ULID into a Crockford Base32 encoded string.

translates alphanumerics into a sentinel ulid value

Returns the timestamp of an encoded or unencoded ULID

The underlying schema type.