Packages

Database-agnostic types and a composable SQL query builder for Gleam

Current section

Files

Jump to
based src based@testing.erl
Raw

src/based@testing.erl

-module(based@testing).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([adapter/1, with_connection/2]).
-export_type([connection/0]).
-type connection() :: {connection, nil}.
-spec adapter({ok, based:returned(FVC)} | {error, nil}) -> fun((based:'query'(FVC), any()) -> {ok,
based:returned(FVC)} |
{error, nil}).
adapter(Returned) ->
fun(_, _) -> Returned end.
-spec with_connection(
{ok, based:returned(FVJ)} | {error, nil},
fun((based:db(FVJ, connection())) -> {ok, FVP} | {error, FVQ})
) -> {ok, FVP} | {error, FVQ}.
with_connection(Returned, Callback) ->
_pipe = {connection, nil},
_pipe@1 = {db, _pipe, adapter(Returned)},
Callback(_pipe@1).