tinyplex / tinybase

The reactive data store for local‑first apps.
https://tinybase.org
MIT License
3.78k stars 80 forks source link

Dynamic queries using store values #191

Open tallenh opened 1 day ago

tallenh commented 1 day ago

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 commented 1 day ago

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