diff options
-rw-r--r-- | dbcontrollerfunctions.lua | 6 | ||||
-rw-r--r-- | dbmodelfunctions.lua | 15 |
2 files changed, 19 insertions, 2 deletions
diff --git a/dbcontrollerfunctions.lua b/dbcontrollerfunctions.lua index 6d83bd4..73eb3f0 100644 --- a/dbcontrollerfunctions.lua +++ b/dbcontrollerfunctions.lua @@ -1,7 +1,11 @@ module(..., package.seeall) +function listdatabases(self) + return self.model.list_databases(self, self.clientdata) +end + function listtables(self) - return self.model.list_tables() + return self.model.list_tables(self, self.clientdata) end function viewtable(self) diff --git a/dbmodelfunctions.lua b/dbmodelfunctions.lua index 3bc2382..09e3edf 100644 --- a/dbmodelfunctions.lua +++ b/dbmodelfunctions.lua @@ -2,7 +2,20 @@ module(..., package.seeall) -- Helper library for model functions for viewing and editing database entries -- Relies heavily on the acf-lib/db.lua library (db object passed into each function) -function list_tables(db) +function list_databases(db, self, clientdata) + local retval = {} + local errtxt + local res, err = pcall(function() + retval = db.listdatabases() + end) + if not res and err then + errtxt = err + end + + return cfe({ type="list", value=retval, label="List of Databases", errtxt=errtxt }) +end + +function list_tables(db, self, clientdata) local retval = {} local errtxt local res, err = pcall(function() |