glesia
Safe-ish Gleam bindings for Erlang Mnesia.
Glesia wraps the common Mnesia lifecycle and data operations while keeping
the dynamic BEAM boundary explicit. Table names and attributes are atoms;
records cross the FFI boundary as Dynamic values and can be decoded by
callers with normal Gleam decoders.
Types
pub type MnesiaError {
AlreadyExists
NotFound
Timeout
BadType(String)
Abort(String)
Unknown(String)
}
Constructors
-
AlreadyExists -
NotFound -
Timeout -
BadType(String) -
Abort(String) -
Unknown(String)
pub type ReadResult {
ReadOk(records: List(dynamic.Dynamic))
ReadError(reason: dynamic.Dynamic)
}
Constructors
-
ReadOk(records: List(dynamic.Dynamic)) -
ReadError(reason: dynamic.Dynamic)
pub type SchemaResult {
SchemaOk
SchemaError(reason: dynamic.Dynamic)
}
Constructors
-
SchemaOk -
SchemaError(reason: dynamic.Dynamic)
pub type SimpleResult {
SimpleOk
SimpleError(reason: dynamic.Dynamic)
}
Constructors
-
SimpleOk -
SimpleError(reason: dynamic.Dynamic)
pub type StorageType {
RamCopies
DiscCopies
DiscOnlyCopies
}
Constructors
-
RamCopies -
DiscCopies -
DiscOnlyCopies
pub type TableCreateResult {
TableCreateOk
TableCreateAlreadyExists
TableCreateError(reason: dynamic.Dynamic)
}
Constructors
-
TableCreateOk -
TableCreateAlreadyExists -
TableCreateError(reason: dynamic.Dynamic)
pub type TransactionResult {
TransactionOk(value: dynamic.Dynamic)
TransactionAbort(reason: dynamic.Dynamic)
}
Constructors
-
TransactionOk(value: dynamic.Dynamic) -
TransactionAbort(reason: dynamic.Dynamic)
Values
pub fn create_local_schema() -> Result(Nil, MnesiaError)
pub fn create_ram_table(
table: atom.Atom,
attributes: List(atom.Atom),
) -> Result(Nil, MnesiaError)
pub fn create_schema(
nodes: List(atom.Atom),
) -> Result(Nil, MnesiaError)
pub fn create_table(
table: atom.Atom,
attributes: List(atom.Atom),
storage_type: StorageType,
table_type: TableType,
) -> Result(Nil, MnesiaError)
pub fn delete_local_schema() -> Result(Nil, MnesiaError)
pub fn delete_schema(
nodes: List(atom.Atom),
) -> Result(Nil, MnesiaError)
pub fn dirty_delete(
table: atom.Atom,
key: dynamic.Dynamic,
) -> Result(Nil, MnesiaError)
pub fn dirty_read(
table: atom.Atom,
key: dynamic.Dynamic,
) -> Result(List(dynamic.Dynamic), MnesiaError)
pub fn dirty_read_decoded(
table: atom.Atom,
key: dynamic.Dynamic,
decoder: decode.Decoder(value),
) -> Result(List(value), MnesiaError)
pub fn dirty_write(
record: dynamic.Dynamic,
) -> Result(Nil, MnesiaError)
pub fn set_dir(path: String) -> Result(Nil, MnesiaError)
pub fn start() -> Result(Nil, MnesiaError)
pub fn stop() -> Result(Nil, MnesiaError)
pub fn transaction(
fun: fn() -> value,
) -> Result(dynamic.Dynamic, MnesiaError)