Skip to content
Discussion options

You must be logged in to vote

Hi @eslksw! I'm Dosu and I’m helping the wails team.

There isn’t an official Wails-specific best practice for managing DB connections, but the recommended approach is to add your DB connection (or persistence layer) as a field on your App struct. Initialize it in the App’s startup method and clean it up in shutdown. This leverages Wails’ lifecycle hooks and keeps your resources encapsulated, avoiding the pitfalls of global variables (like concurrency issues and testability problems). You can then expose DB operations as public methods on your App struct, which are easily bound to the frontend via Wails’ binding mechanism. This pattern is consistent with how Wails expects you to manage ot…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by eslksw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant