This doesn’t seem to be terribly well documented, so for future reference:
F = fun() -> mnesia:select(Tab,[{'_',[],['$_']}]) end, mnesia:activity(transaction, F).
This doesn’t seem to be terribly well documented, so for future reference:
F = fun() -> mnesia:select(Tab,[{'_',[],['$_']}]) end, mnesia:activity(transaction, F).
I have a webmachine app that uses Mnesia as an in-memory DB. To begin with, I was just calling mnesia:start() in the erlang terminal provided after running start.sh. But, after forgetting to start it a couple of times, I looked for a better solution.
My first stop, the internet, didn’t provide me with any answers (either it should be obvious, or I was using the wrong keywords!). So I decided to try adding it to the dependency list in my application resource file (.app.src).
{application, restbucks, [ {description, "restbucks"}, {vsn, "1"}, {modules, []}, {registered, []}, {applications, [ kernel, ... snip ... webmachine, mnesia ]}, {mod, { restbucks_app, []}}, {env, []} ]}.
Unfortunately, that didn’t seem to have any effect whatsoever.
Luckily, I’d discovered through my adventures with eunit, that erl can take a number of arguments (-s) that will be executed when starting. So I modified my start.sh script appropriately:
exec erl -pa $PWD/ebin $PWD/deps/*/ebin -boot start_sasl -s mnesia start -s reloader -s restbucks
Whether this is a good idea remains to be seen, but it seems to work!