aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-05-23 23:42:23 -0400
committerPaul Duncan <pabs@pablotron.org>2016-05-23 23:42:23 -0400
commit2a87c79df590a1ad55420900ce0709f4a881a448 (patch)
treefd0eaa24f5202071263fd0254558f891541b9ce9 /src
parent36ab1673930235f0883a8bd824df24634a799a2a (diff)
downloadguff-2a87c79df590a1ad55420900ce0709f4a881a448.tar.bz2
guff-2a87c79df590a1ad55420900ce0709f4a881a448.zip
add {blog,page,project}/get
Diffstat (limited to 'src')
-rw-r--r--src/guff.cr76
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