lode/types/enum
Ecto.Enum — map a user-defined Gleam type to string or integer DB values.
Elixir’s Ecto.Enum maps atoms; Gleam has no atoms, so the user supplies an
explicit mapping between their own variant type a and the DB representation.
No parameterized-type behaviour is needed — this is a plain LodeType
constructor.
type Status { Active Archived } let status_type = enum.string_enum(“status”, [#(Active, “active”), #(Archived, “archived”)])
Values
pub fn int_enum(
name name: String,
values values: List(#(a, Int)),
) -> type_.LodeType(a)
Build an integer-backed enum from variant/int pairs.
pub fn string_enum(
name name: String,
values values: List(#(a, String)),
) -> type_.LodeType(a)
Build a string-backed enum from variant/string pairs.