[erlang-questions] Reading from mnesia
Oscar Muñoz Garrigós
osmuogar@REDACTED
Tue Aug 18 01:19:00 CEST 2015
Hi guys,
I am creating a chat application android - erlang.
The problem is i can't read from the table. What am i doing wrong?
-record(message,{leido, from, to, text}).
install(Nodes) ->
mnesia:create_schema(Nodes),
mnesia:start(),
mnesia:create_table(
message,
[
{attributes, record_info(fields, message)}
]
).
write_message(From, To, Text)->
Trans = fun()->mnesia:write(#message{leido = false,from = From, to =
To, text = Text}) end,
mnesia:transaction(Trans).
read_message(To)->
Trans = fun() -> mnesia:read({message,To}) end,
mnesia:transaction(Trans).
*leido marks if the message has been readed
Another question is i want to read only messages where leido = false, ¿how
can i do it?
Thank you all
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150818/6e631aa8/attachment.htm>
More information about the erlang-questions
mailing list