I have a ram_copies mnesia set up and I can insert the records, and I can print the them using the following code located here: How to read all the records of mnesia database in erlang?
Start Record:
-record(someRecord, {a=null, b=null}).
Table:
mnesia:create_table(someRecord,
[{attributes, record_info(fields, someRecord)},
{index, [#someRecord.b]},
{ram_copies, Nodes},
{type, set}]),
Inserting:
i(rA, rB) ->
F = fun() -> mnesia:write(#someRecord{a=rA, b=rB}) end,
mnesia:transaction(F).
Reading:
r(rB) ->
F = fun() -> mnesia:read({someRecord, rB}) end,
mnesia:transaction(F).
This returns {atomic, Result} and Result is empty.
Wondering what I am doing wrong.
Thanks!
Update: It turns out that if I use the record "a" as they key it works. But why? I have it set to record "b" for key.
mnesia:index_read(someRecord, B, #someRecord.b)
? – Dogbertmnesia
needs to maintain. – Dogbert