module Guff class PostModel < Model SQL = { get_posts: " SELECT a.post_id, a.name, a.body, a.html FROM posts a JOIN ( SELECT DISTICT c.post_id FROM post_tags c JOIN tags d ON (d.tag_id = c.tag_id) JOIN (VALUES (%{tags}) e(name) ON (e.name = d.name) ) b WHERE c.%{filter} ORDER BY %{sort} %{dir} OFFSET ? LIMIT ? ", } def get_posts(req) # TODO [{foo: "bar"}, {foo: "asdf"}] end def add_post(req) # TODO: return post id {ok: true} end def remove_posts(req) # TODO {ok: true} end def set_tags(req) # TODO {ok: true} end end end