-module(based). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([exec/2, all/2, one/2, string/1, int/1, float/1, bool/1, null/0]). -export_type([value/0, 'query'/1, returned/1, db/2]). -type value() :: {string, binary()} | {int, integer()} | {float, float()} | {bool, boolean()} | null. -type 'query'(FQU) :: {'query', binary(), list(value()), gleam@option:option(fun((gleam@dynamic:dynamic_()) -> {ok, FQU} | {error, list(gleam@dynamic:decode_error())}))}. -type returned(FQV) :: {returned, integer(), list(FQV)}. -type db(FQW, FQX) :: {db, FQX, fun(('query'(FQW), FQX) -> {ok, returned(FQW)} | {error, nil})}. -spec exec('query'(FRY), db(FRY, any())) -> {ok, returned(FRY)} | {error, nil}. exec(Query, Db) -> _pipe = Query, (erlang:element(3, Db))(_pipe, erlang:element(2, Db)). -spec all('query'(FRJ), db(FRJ, any())) -> {ok, returned(FRJ)} | {error, nil}. all(Query, Db) -> exec(Query, Db). -spec one('query'(FRR), db(FRR, any())) -> {ok, FRR} | {error, nil}. one(Query, Db) -> gleam@result:'try'( exec(Query, Db), fun(Returned) -> {returned, _, Rows} = Returned, gleam@result:'try'( begin _pipe = Rows, gleam@list:first(_pipe) end, fun(Row) -> {ok, Row} end ) end ). -spec string(binary()) -> value(). string(Value) -> {string, Value}. -spec int(integer()) -> value(). int(Value) -> {int, Value}. -spec float(float()) -> value(). float(Value) -> {float, Value}. -spec bool(boolean()) -> value(). bool(Value) -> {bool, Value}. -spec null() -> value(). null() -> null.