webmcp

view demo-app/model/medium.lua @ 499:b36e366bba2b

Added SHA-3 hashing functions (using compact Keccak code)
author jbe
date Sun Aug 13 03:22:48 2017 +0200 (2017-08-13)
parents 9fdfb27f8e67
children
line source
1 Medium = mondelefant.new_class()
2 Medium.table = 'medium'
4 Medium:add_reference{
5 mode = 'm1', -- many (m) Medium entries can refer to one (1) MediaType
6 to = "MediaType", -- name of referenced model (quoting avoids auto-loading here)
7 this_key = 'media_type_id', -- own key in medium table
8 that_key = 'id', -- other key in media_type table
9 ref = 'media_type', -- name of reference
10 back_ref = nil, -- not used for m1 relation!
11 default_order = nil -- not used for m1 relation!
12 }
14 Medium:add_reference{
15 mode = '1m', -- one (1) Medium has many (m) Classifications
16 to = "Classification", -- name of referenced model (quoting avoids auto-loading here)
17 this_key = 'id', -- own key in medium table
18 that_key = 'medium_id', -- other key in classification table
19 ref = 'classifications', -- name of reference
20 back_ref = 'medium', -- each autoloaded classification automatically refers back to the Medium
21 default_order = '"genre_id"' -- order classifications by SQL expression "genre_id"
22 }
24 Medium:add_reference{
25 mode = 'mm', -- many (m) Media belong to many (m) Genres
26 to = "Genre", -- name of referenced model (quoting avoids auto-loading here)
27 this_key = 'id', -- (primary) key of medium table
28 that_key = 'id', -- (primary) key of genre talbe
29 connected_by_table = 'classification', -- table connecting media with genres
30 connected_by_this_key = 'medium_id', -- key in classification table referencing media
31 connected_by_that_key = 'genre_id', -- key in classification table referencing genres
32 ref = 'genres', -- name of reference
33 back_ref = nil, -- not used for mm relation!
34 default_order = '"genre"."name", "genre"."id"' -- mm references need qualified names in SQL order expression!
35 }
37 Medium:add_reference{
38 mode = '1m', -- one (1) Medium has many (m) Tracks
39 to = "Track", -- name of referenced model (quoting avoids auto-loading here)
40 this_key = 'id', -- own key in medium table
41 that_key = 'medium_id', -- other key in track table
42 ref = 'tracks', -- name of reference
43 back_ref = 'medium', -- each autoloaded classification automatically refers back to the Medium
44 default_order = '"position"' -- order tracks by SQL expression "position"
45 }

Impressum / About Us