[erlang-questions] How best to return db query

lloyd@REDACTED lloyd@REDACTED
Sun Feb 7 19:38:01 CET 2016


Hello,

I have this mnesia query:


get_note(ID) ->
    Query =
        fun() ->
            mnesia:read({?TABLE, ID})
        end,
    {atomic, Results} = mnesia:transaction(Query),
    Results.

It returns either a list containing one or more valid records or an empty list.

Would it be better to return something like:

{ok, Records} | {error, data_not_found}

Thanks,

LRP








More information about the erlang-questions mailing list