forked from Movimento5StelleLazio/ParlamentoElettronicoM5S
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvote.lua
executable file
·34 lines (30 loc) · 787 Bytes
/
vote.lua
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
Vote = mondelefant.new_class()
Vote.table = 'vote'
Vote.primary_key = { "initiative_id", "member_id" }
Vote:add_reference{
mode = 'm1',
to = "Issue",
this_key = 'issue_id',
that_key = 'id',
ref = 'issue',
}
Vote:add_reference{
mode = 'm1',
to = "Initiative",
this_key = 'initiative_id',
that_key = 'id',
ref = 'initiative',
}
Vote:add_reference{
mode = 'm1',
to = "Member",
this_key = 'author_id',
that_key = 'id',
ref = 'author',
}
function Vote:by_pk(initiative_id, member_id)
return self:new_selector()
:add_where{ "initiative_id = ? AND member_id = ?", initiative_id, member_id }
:optional_object_mode()
:exec()
end