diff options
-rw-r--r-- | src/guff.cr | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/guff.cr b/src/guff.cr index 3f36363..19a3ace 100644 --- a/src/guff.cr +++ b/src/guff.cr @@ -484,6 +484,29 @@ module Guff SET layout_id = (SELECT layout_id FROM layouts WHERE layout = ?) WHERE post_id = ? ", + + get: " + SELECT a.post_id, + a.site_id, + c.state, + a.posted_at, + a.expires_at, + a.slug, + a.slug_lock, + a.name, + a.body, + d.layout + + FROM posts a + JOIN pages b + ON (b.post_id = a.post_id) + JOIN states c + ON (c.state_id = a.state_id) + JOIN layouts d + ON (d.layout_id = b.layout_id) + + WHERE a.post_id = ? + ", } def get_id( @@ -556,6 +579,10 @@ module Guff end end end + + def get(post_id : Int64) + @context.dbs.ro.row(SQL[:get], [post_id.to_s]) + end end class ProjectModel < Model @@ -588,6 +615,27 @@ module Guff SET repo_url = ? WHERE post_id = ? ", + + get: " + SELECT a.post_id, + a.site_id, + c.state, + a.posted_at, + a.expires_at, + a.slug, + a.slug_lock, + a.name, + a.body, + b.repo_url + + FROM posts a + JOIN projects b + ON (b.post_id = a.post_id) + JOIN states c + ON (c.state_id = a.state_id) + + WHERE a.post_id = ? + ", } def get_id( @@ -660,6 +708,10 @@ module Guff end end end + + def get(post_id : Int64) + @context.dbs.ro.row(SQL[:get], [post_id.to_s]) + end end class BlogModel < Model @@ -686,6 +738,26 @@ module Guff add: " INSERT INTO blogs(post_id) VALUES (?) ", + + get: " + SELECT a.post_id, + a.site_id, + c.state, + a.posted_at, + a.expires_at, + a.slug, + a.slug_lock, + a.name, + a.body + + FROM posts a + JOIN blogs b + ON (b.post_id = a.post_id) + JOIN states c + ON (c.state_id = a.state_id) + + WHERE a.post_id = ? + ", } def get_id( @@ -802,6 +874,10 @@ module Guff body: body, ) end + + def get(post_id : Int64) + @context.dbs.ro.row(SQL[:get], [post_id.to_s]) + end end class UserModel < Model |