diff --git a/examples/base/main.go b/examples/base/main.go index 7af1d144..04b8f1dc 100644 --- a/examples/base/main.go +++ b/examples/base/main.go @@ -5,6 +5,7 @@ import ( "os" "path/filepath" "strings" + "time" "github.com/pocketbase/pocketbase" "github.com/pocketbase/pocketbase/apis" @@ -52,6 +53,14 @@ func main() { "fallback the request to index.html on missing static path (eg. when pretty urls are used with SPA)", ) + var queryTimeout int + app.RootCmd.PersistentFlags().IntVar( + &queryTimeout, + "queryTimeout", + 30, + "the default SELECT queries timeout in seconds", + ) + app.RootCmd.ParseFlags(os.Args[1:]) // --------------------------------------------------------------- @@ -70,6 +79,11 @@ func main() { Dir: migrationsDir, }) + app.OnAfterBootstrap().Add(func(e *core.BootstrapEvent) error { + app.Dao().ModelQueryTimeout = time.Duration(queryTimeout) * time.Second + return nil + }) + app.OnBeforeServe().Add(func(e *core.ServeEvent) error { // serves static files from the provided public dir (if exists) e.Router.GET("/*", apis.StaticDirectoryHandler(os.DirFS(publicDir), indexFallback))