[erlang-questions] mnesia question
lloyd@REDACTED
lloyd@REDACTED
Sun Sep 17 21:40:48 CEST 2017
Hello,
Life gets tricky in the literary world. Some authors use a pen name on their books rather than legal name. But it's quite possible for two different authors to use the same pen name. So pen name is not a good key to associate an author and a book. But ISBN does nicely.
Email provides a convenient user name for access to a website. It minimizes the problem of two different people having the same user name.
So in my user record I use email as the primary key. But, at creation of the record, I also generate a unique user_id in slot five in the user record. And I create an index to locate the user by user_id. This is handy, because I can use user_id to locate all of the user's books.
So one would think that this query would work:
get_member_by_member_id(MemberID) when is_list(MemberID)->
Query =
fun() ->
mnesia:read({?TABLE, MemberID})
end,
{atomic, Results} = mnesia:transaction(Query),
case length(Results) < 1 of
true -> [];
false -> hd(Results)
end.
But it doesn't. It returns an empty list.
Not doubt I've forgotten something about mnesia or never learned it.
Any help?
Many thanks,
LRP
More information about the erlang-questions
mailing list