aboutsummaryrefslogtreecommitdiff
path: root/src/guff/model.cr
diff options
context:
space:
mode:
Diffstat (limited to 'src/guff/model.cr')
-rw-r--r--src/guff/model.cr45
1 files changed, 42 insertions, 3 deletions
diff --git a/src/guff/model.cr b/src/guff/model.cr
index ce24427..515af4e 100644
--- a/src/guff/model.cr
+++ b/src/guff/model.cr
@@ -1,10 +1,49 @@
module Guff
class Model
- def initialize(@models : Models)
+ getter :db
+
+ def initialize(@models : Models, @templates : TemplateCache)
+ @db = TemplateDatabase.new(@models.db, @templates)
+ end
+
+ def one(
+ key : Symbol,
+ args : Array(String) | Hash(String, String) | Nil,
+ tmpl_args : Hash(String, String) | Nil
+ )
+ @db.one(key, args, tmpl_args)
+ end
+
+ def row(
+ key : Symbol,
+ args : Array(String) | Hash(String, String) | Nil,
+ tmpl_args : Hash(String, String) | Nil
+ )
+ @db.row(key, args, tmpl_args)
+ end
+
+ def all(
+ key : Symbol,
+ args : Array(String) | Hash(String, String) | Nil,
+ tmpl_args : Hash(String, String) | Nil,
+ &block : Proc(Hash(String, ::SQLite3::Value), Nil) \
+ )
+ @db.all(key, args, tmpl_args, &block)
+ end
+
+ def query(
+ key : Symbol,
+ args : Array(String) | Hash(String, String) | Nil,
+ tmpl_args : Hash(String, String) | Nil
+ )
+ @db.query(key, args, tmpl_args)
end
- def db
- @models.db
+ def template(
+ key : Symbol,
+ args : Hash(String, String) | Nil
+ )
+ @db.template(key, args)
end
end
end