webmcp
view demo-app/model/genre.lua @ 3:795b764629ca
Version 1.0.3
Important bugfix related to internal forwards (Bug was introduced by the restriction of views with underscore prefix in Version 1.0.2)
Important bugfix related to internal forwards (Bug was introduced by the restriction of views with underscore prefix in Version 1.0.2)
author | jbe |
---|---|
date | Thu Dec 10 12:00:00 2009 +0100 (2009-12-10) |
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 }