webmcp

view demo-app/model/genre.lua @ 548:a006593b747c

Basic support for database array types (integers and strings)
author jbe
date Mon Oct 21 19:55:13 2019 +0200 (2019-10-21)
parents 9fdfb27f8e67
children
line source
1 Genre = mondelefant.new_class()
2 Genre.table = 'genre'
4 Genre:add_reference{
5 mode = '1m', -- one (1) Genre is used for many (m) Classifications
6 to = "Classification", -- name of referenced model (using a string instead of reference avoids auto-loading here)
7 this_key = 'id', -- own key in genre table
8 that_key = 'genre_id', -- other key in classification table
9 ref = 'classifications', -- name of reference
10 back_ref = 'genre', -- each autoloaded Classification automatically refers back to the Genre
11 default_order = '"media_id"' -- order Classifications by SQL expression "media_id"
12 }
14 Genre:add_reference{
15 mode = 'mm', -- many (m) Genres belong to many (m) Medium entries
16 to = "Medium", -- name of referenced model (quoting avoids auto-loading here)
17 this_key = 'id', -- (primary) key of genre table
18 that_key = 'id', -- (primary) key of medium talbe
19 connected_by_table = 'classification', -- table connecting genres with media
20 connected_by_this_key = 'genre_id', -- key in connection table referencing genres
21 connected_by_that_key = 'medium_id', -- key in connection table referencing media
22 ref = 'media', -- name of reference
23 back_ref = nil, -- not used for mm relation!
24 default_order = '"medium"."name", "medium"."id"' -- mm references need qualified names in SQL order expression!
25 }

Impressum / About Us