Dynamic queries using store values
Is your feature request related to a problem? Please describe. Would like to have a way to pass dynamic parameters to a query
Describe the solution you'd like On "where" and possibly "has", along with a getcell function pass along a getvalue function that will return a reactive value from the store. Would allow something like this:
queries.setQueryDefinition("filtered_items", "items", ({ select, where }) => {
select("name");
where((getcell, getvalue) => getcell("name").includes(getvalue("filter_string")));
});
then if you run:
store.setValue("filter_string", "test")
would cause the query to update with the new value. Reactive dynamic queries.
@tallenh Could you do the same thing with a join?
Yeah this is a good idea. I think this falls under #47?
@waynesbrain If you are asking if join should have similar functionality, yes I think that could be useful
@jamesgpearce I am currently doing similar things as #47 and it works well. It is powerful that a listener gets updated if you manually change the query. I am using TinyBase in a hobby Svelte 5 project and it is easy to "refire" the query when some state changes. I was thinking about a framework agnostic way to accomplish something similar.
Not quite what you asked for, but do check out the release notes for v7.2 beta and see if this will work for you... https://github.com/tinyplex/tinybase/releases/tag/v7.2.0-beta.2
💥 https://github.com/tinyplex/tinybase/releases/tag/v7.2.0
Note that params are reactive so you can read and listen to them, both directly and with React hooks. Enjoy!