-
Notifications
You must be signed in to change notification settings - Fork 24
/
.iex.exs
57 lines (42 loc) · 938 Bytes
/
.iex.exs
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
require Logger
alias Memento.{
Table,
Query,
Schema,
Mnesia,
Transaction,
Error,
MnesiaException,
Support,
Support.Definitions,
}
# Table Aliases
alias Definitions.Tables.User, as: U
alias Definitions.Tables.Email, as: E
alias Definitions.Tables.Movie, as: M
alias Definitions.Tables.Nested, as: N
# Create Tables
Table.create(U) |> inspect |> Logger.debug
Table.create(E) |> inspect |> Logger.debug
Table.create(M) |> inspect |> Logger.debug
Table.create(N) |> inspect |> Logger.debug
# Seed with some values
U.seed
E.seed
M.seed
N.seed
# Transaction Helpers
trx = &Support.Mnesia.transaction/1
mrx = &:mnesia.transaction/1
# Select Query Helper
select = fn (table, query, opts) ->
Memento.transaction! fn ->
Query.select(table, query, opts)
end
end
# Raw Query Helper
raw = fn (table, match_spec, opts) ->
Memento.transaction! fn ->
Query.select_raw(table, match_spec, opts)
end
end