Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic queries using store values #191

Open
tallenh opened this issue Oct 24, 2024 · 3 comments
Open

Dynamic queries using store values #191

tallenh opened this issue Oct 24, 2024 · 3 comments

Comments

@tallenh
Copy link

tallenh commented Oct 24, 2024

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.

@waynesbrain
Copy link

@tallenh Could you do the same thing with a join?

@jamesgpearce
Copy link
Contributor

Yeah this is a good idea. I think this falls under #47?

@tallenh
Copy link
Author

tallenh commented Oct 27, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants