[erlang-questions] How best to return db query
Sergej Jurečko
sergej.jurecko@REDACTED
Sun Feb 7 19:45:39 CET 2016
An empty result to a db query is not an error.
Sergej
On Feb 7, 2016 7:38 PM, <lloyd@REDACTED> wrote:
> 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
>
>
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160207/e1a9a2f0/attachment.htm>
More information about the erlang-questions
mailing list