how to use solid router with tauri and a sqlite database
I am making a Tauri app that has a pretty basic database to hold lists and projects created by the user. I currently have a singleton database class with functions for database actions like this:
and then I have been calling this in my components by doing something like this:
This has worked so far but I feel like there has got to be a way to use solid router functions like
createAsync
, action
, and query
to do this better but I am not really familiar with these at all. How can I set this stuff up to have better usage in my components? Right now, I'm hitting some complications trying to have a list of projects that I fetch and display with a <For each={projects} />
but I can't figure out how to do refetching and stuff in a good way.1 Reply
The code you’ve posted would remain mostly the same.
With query you can wrap your getter functions and call them inside a component e.g.
For mutations you do the same with actions.
Wrap the wrapper function and then use useAction and call it in an event handler. Use one of the response helpers to revalidate and refetch affected queries.
E.g.
Other response helpers on this page and the following ones
https://docs.solidjs.com/solid-router/reference/response-helpers/json
json -
Documentation for SolidJS, the signals-powered UI framework