Refactored models code to follow a better approach for opening and closing the database connection

This commit is contained in:
Gregory Ballantine
2023-11-28 14:40:12 -05:00
parent 19670e9abd
commit bae65994f8
4 changed files with 42 additions and 7 deletions

View File

@ -19,7 +19,9 @@ func main() {
f := flamego.Classic()
// initialize database
models.InitDatabase()
models.Open()
// defer database connection closing til the app exits
defer models.Close()
// initialize templating engine
f.Use(template.Templater())