From c4c30f1f86246e5e2b39a005329e6d7adb889101 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Thu, 3 Feb 2022 13:27:29 +0100 Subject: [PATCH] Table model etc --- src/db_models.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/db_models.rb b/src/db_models.rb index 20b5b22..820ae0b 100644 --- a/src/db_models.rb +++ b/src/db_models.rb @@ -1,6 +1,18 @@ -class TableModel +class TableModel # Base model attr_reader :table_name def initialize(table_name) @table_name = table_name end + + private def get(entity, filter="") + db = db_handle # get the db handle + query = "SELECT #{entity} FROM #{@table_name} " # create the query string + if filter != "" then query += "WHERE #{filter}" end + + db.execute query + end +end + + +class User < TableModel end