use better naming for uri and check it

This commit is contained in:
Robin Olsen
2026-03-10 13:31:18 +01:00
parent 8945341250
commit ce4c815ef5
3 changed files with 19 additions and 5 deletions

View File

@@ -17,7 +17,12 @@ var SubmitCmd = &cobra.Command{
return fmt.Errorf("application context not initialized")
}
db, err := storage.NewMongoStorageInteractive(cmd.Context(), app.Config.MongoURI)
if app.Config.DB_URI == "" {
cmd.Println("No database URI provided in environment, survey responses will not be submitted.")
return nil
}
db, err := storage.NewMongoStorageInteractive(cmd.Context(), app.Config.DB_URI)
if err != nil {
return fmt.Errorf("failed to connect to database: %w", err)
}