UUIDv7 (UUIDv7 v0.6.0)
View SourceUUIDv7 for Elixir.
Used for generating version 7 UUIDs using submillisecond clock precision.
Includes Ecto.Type
implementations.
Examples
iex> UUIDv7.generate()
"018e90d8-06e8-7f9f-bfd7-6730ba98a51b"
iex> UUIDv7.bingenerate()
<<1, 142, 144, 216, 6, 232, 127, 159, 191, 215, 103, 48, 186, 152, 165, 27>>
Summary
Functions
Generates a version 7 UUID in the binary format.
Decode a string representation of a UUID to the raw binary version.
Encode a raw UUID to the string representation.
Extract the millisecond timestamp from the UUID.
Generates a version 7 UUID using submilliseconds for increased clock precision.
Types
Functions
Generates a version 7 UUID in the binary format.
Example
iex> UUIDv7.bingenerate()
<<1, 142, 144, 216, 6, 232, 127, 159, 191, 215, 103, 48, 186, 152, 165, 27>>
Decode a string representation of a UUID to the raw binary version.
Example
iex> UUIDv7.decode("018e90d8-06e8-7f9f-bfd7-6730ba98a51b")
<<1, 142, 144, 216, 6, 232, 127, 159, 191, 215, 103, 48, 186, 152, 165, 27>>
Encode a raw UUID to the string representation.
Example
iex> UUIDv7.encode(<<1, 142, 144, 216, 6, 232, 127, 159, 191, 215, 103, 48, 186, 152, 165, 27>>)
"018e90d8-06e8-7f9f-bfd7-6730ba98a51b"
Extract the millisecond timestamp from the UUID.
Example
iex> UUIDv7.extract_timestamp("018ecb40-c457-73e6-a400-000398daddd9")
1712807003223
@spec generate() :: t()
Generates a version 7 UUID using submilliseconds for increased clock precision.
Example
iex> UUIDv7.generate()
"018e90d8-06e8-7f9f-bfd7-6730ba98a51b"