I have a checkbox variable (boolean) which I’d like to use as a filter on a Supabase query.
I’m unsure how to lookup the column of a nested JSONB object in a filter as the operator available I see “is exactly” and to what the formula might look like, and if this is possible?
Performance is important so I need this to run on the backend (Supabase side) and I know it should be done at the data collection level. I’m hoping this is within the latest SDK release earlier this year.
The filters are still a problem as operators at the collection level don’t work. But it does work on the table/frontend view. However, I’d like to query the DB on the backend and need to find the “true” values within this JSON metadata.
After a lot of messing around i was able to crack this.
I couldn’t get the “->” to work for me at all. But i found this on the superbase forum Supabase Javascript Client - Using filters (specifically the
“Filter referenced tables” item)
I have just come across an alterative solution. Create a view in superbase with the column you want to filter joined. But not apply any filters at the superbase level. The view will basically just be your the table + 1 extra column.
Then in weweb create a new collection and use this new view as your data source. You can then apply filters at a workflow and a collection level. Just remember, when modifying the data to do it against the original dataset, not the view.
Hello, nice solution For anyone else wondering, I actually wrote an article about this. You actually should be able to use the … spread operator to get the data to the same level in the object, which then allows you to filter it.
By the way, views tend to get slow with many items, because views actually aren’t indexed. So I try to avoid them and use them only for analytical purposes, or some tables that I know will have a few records (such as some user-facing tables etc.) I also use views for things like evaluating things, for example an event’s attendance etc.
While the spread operator allows you to choose the field for filtering (in a collection), you can’t actually use it to filter, as weweb then tries to filter on the original collection with that column name, and gets an error. I’ve not managed to make it work at least.
Yeah now I see it, you’re right. The issue is that WeWeb parses it as a direct column as you said. With the Workflow Actions it works though. You just need to do the [table].column instead of the column directly. Nice catch. I already raised this issue of filtering being different for collections with @Alexis when the actions first came out, it would be amazing to have the same filtering on collections as well.
Recently I just stick to creating my own “collections” workflows as shown in the pic, with the actions.