diff --git a/app.go b/app.go index 3df4052..d442b88 100644 --- a/app.go +++ b/app.go @@ -5,17 +5,19 @@ import ( "fmt" "github.com/gen2brain/beeep" + "gorm.io/gorm" ) // App struct type App struct { ctx context.Context + db *gorm.DB } // NewApp creates a new App application struct -func NewApp() *App { +func NewApp(db *gorm.DB) *App { - return &App{} + return &App{db: db} } // startup is called when the app starts. The context is saved diff --git a/main.go b/main.go index d937fb4..057a33b 100644 --- a/main.go +++ b/main.go @@ -15,8 +15,8 @@ var assets embed.FS func main() { // Create an instance of the app structure - app := NewApp() db := model.InitDB() + app := NewApp(db) things := &things.Service{DB: db} // Create application with options