ORM (Object-relational mapping) application implemented in Erlang. Still in very much beta :-)
Currently erldb supports two different backends; ets and mysql. We are hoping to support more.
This section will be written soon
A model is defined by a basic set of attributes.
There is currently two different relations in erldb;
-relation(has, AMOUNT, MODEL_NAME).
- Defines a one -> N relation.
-relation(belongs_to, MODEL_NAME).
Pre-triggers can be defined by including the function _pre_TRIGGERNAME/1
where the triggername can be one of: update, lookup, delete or insert.
Post-triggers are defined almost the same as for pre-triggers. Just change pre to _post. Example: _post_update/1
Right now you have to compile the models yourself. Please take a look at the compilemodel-script located in the priv-directory of this repository.
To build erldb use rebar3:
$ rebar3 compile
To generate documentation of erldb:
$ rebar3 edocs
Check the models/
-directory for example models. To compile the model tags.erl;
$ rebar3 shell
...compilation output...
1> erldb_compiler:compile("examples/tags.erl", [{includedir, "./include"}, {outdir, "."}]).
{ok,tags}
Now you can read the record definitions for each of the models within erlang:
2> rr("include/tags.hrl").
[tags]
3> A = #tags{}.
#tags{id = undefined,title = "Fancy title",text = undefined,
created = undefined}
4> B = A:uppercase_title().
"FANCY TITLE"
5> B:save()
{ok,#tags{author_id = undefined,id = id,
title = "FANCY TITLE",text = undefined,created = undefined}}
6> erldb:find(tags, []).
{ok,[#tags{author_id = undefined,id = id,
title = "FANCY TITLE",text = undefined,
created = undefined}]}