-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
153 lines (119 loc) · 3.93 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<link href='https://fonts.googleapis.com/css?family=Chivo:900' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen" />
<link rel="stylesheet" type="text/css" href="stylesheets/pygment_trac.css" media="screen" />
<link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print" />
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<title>Erldb</title>
</head>
<body>
<div id="container">
<div class="inner">
<header>
<h1>Erldb</h1>
<h2>ORM implementation in Erlang</h2>
</header>
<section id="downloads" class="clearfix">
<a href="https://github.com/erldb/ErlDB/zipball/master" id="download-zip" class="button"><span>Download .zip</span></a>
<a href="https://github.com/erldb/ErlDB/tarball/master" id="download-tar-gz" class="button"><span>Download .tar.gz</span></a>
<a href="https://github.com/erldb/ErlDB" id="view-on-github" class="button"><span>View on GitHub</span></a>
</section>
<hr>
<section id="main_content">
<h1>erldb</h1>
<p>ORM (Object-relational mapping) application implemented in Erlang.</p>
<h1>Model files</h1>
<p>Check 'tags.erl' in the examples/ directory</p>
<h1>Usage:</h1>
<p>This is the example model that is in examples directory:</p>
<pre><code>
-backend(mnesia, []).
-field(id, string, [primary_key]).
-field(title, string, [{default, "Fancy title"}]).
-field(text, string, []).
-field(created, datetime, []).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Functions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
uppercase_title() ->
ic_util:to_uppercase(Title).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% HOOKS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Cancel update if text is undefined
_pre_update(Object) ->
case Object#tags.text of
undefined ->
stop;
_ ->
{ok, Object}
end.
%% Logs all updates
_post_update(NewObject, UpdateRes) ->
{ok, FP} = file:open("update.log", [append]),
file:write(FP, NewObject),
file:write(FP, "\n"),
file:write(FP, UpdateRes),
file:write(FP, "\n=============\n"),
file:close(FP).
%% Inserts a new object into the database if the title /= undefined
_pre_insert(Object) ->
case Object#tags.title of
undefined ->
stop;
_ ->
{ok, Object}
end.
_post_insert(Object) ->
case Object#tags.title of
"PHP" ->
stop;
_ ->
{ok, Object}
end.
%% Disable all deletions
_pre_delete(_Object) ->
stop.
%% Disable all deletions
_post_delete(Object) ->
stop.
</code></pre>
<p>To compile your code and to compile your models.</p>
<pre><code>
$ make
APP poolboy.app.src
APP erldb.app.src
./priv/compilemodel
model_path: "examples/"
################## "Start compiling" ###################
file "tags.erl"
################## "Done compiling" ###################
</code></pre>
<p>Then start a shell </p>
<pre><code>
$ erl -pa ebin/
Erlang R16B01 (erts-5.10.2) [source-bdf5300] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V5.10.2 (abort with ^G)
1> rr("include/tags.hrl").
[tags]
2> A = #tags{}.
#tags{id = undefined,title = "Fancy title",text = undefined,
created = undefined}
3> A:uppercase_title().
"FANCY TITLE"
4>
</code></pre>
<footer>
Erldb is maintained by <a href="https://github.com/burbas">burbas</a><br> and <a href="https://github.com/burbas">Taure</a><br>
This page was generated by <a href="http://pages.github.com">GitHub Pages</a>. Tactile theme by <a href="http://twitter.com/jasonlong">Jason Long</a>.
</footer>
</div>
</div>
</body>
</html>