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

This commit is contained in:
2025-07-14 13:53:50 -04:00
parent 0f89087134
commit c9ad5df2ed
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())