Only filter collection after having a value in the slot


I am still dealing with filtering the collection in the Firebase database. I made some progress and the picker that I have put in placed is working creating several categories and writing in the query field:


My problem is that it doesn’t show any item in the beginning because the dataslot is empty obviously. I have tried to write all values separated by comma in the default value for the slot (“Principiante”,“Muy fácil”,etc.) but it doesn’t work. Also, I would like one selection in the picker that would allow to show the entire collection. I am not able to figure out how to do it.

Thank you.

I suggest reading the Firebase docs for queries here:

One cannot create ‘where’ with multiple arguments (comma separated list). It’s against Firebase principles. You do have an option to use new “array-contains-any” and “in” queries. Read more from here:

About showing all documents before use selects from picker is not possible at the moment. You’d need to implement some kind of hack into Firebase plugin that it would ignore the Query field when the Data sheet is loaded for the first time. Another hack would be to use array-contains-any and add e.g. “all” to every document and put “all” into Data slot by default.

Thank you so much for your answer. I understand the limitation of the query and I also understand the way to achieve what I am looking for so I have created a new field in my database which contains an array named “categories” and inside that array I am detailing the filters I intent to use later on.

Right now I am just focusing on making the first one to work and there must be something that I am not doing fine. This is the screen where my database sheet is and the array with categories is the second one on the left:

The query I am using is also visible in the Query field. I believe it is fine. However when I select in the picker a value that contains something that is included in some of the arrays, it doesn’t show anything.:

The picker right now has an empty value as default. I thought that it should show something after picking another one. Is there anything I am missing?

I’d suggest you to debug this issue by checking what is the value in Filter data slot. It should work if you have set the picker to save the value in data slot and value is enclosed with quotation marks.

My example script for picker would be something like this: input ="‘input’";

You can debug this with Browser’s Developer tools or by adding text label somewhere on the screen and add data slot as data source for it.

I suggest starting to use Browser’s developer tools for all debugging purposes. It makes everything much easier when you can e.g. run the code line by line and see what’s the problem.

Thank you so much for your answer.

Ok. I created a text field with the data source in the picker and I thought in the beginning that the problem should be not having the quotation marks. But it mustn’t be that for several reasons:

  • When I use the query where(“level”,"==","$slot(“ds_SlotLevel”)"), I don’t need to add any quotation marks. It just work with the same picker and same values. “level” doesn’t contain an array, it is just one string value. I don’t know if using the array in “categories” would be the problem.

  • Coming back to the “categories” where I have an array with all filters enumerated. I have tried to establish a default value in the data slot, so it shows some of the items that belong to one of the categories in the array. It doesn’t show anything. And I cannot write quotation marks in the default value of the data slot as it doesn’t allow me. Apparently it automatically place them.

  • Finally I have created a text field with the data source in the picker to see what the input is. There were no quotation marks in the beginning so I tried to add them in some categories to see if that triggers the query. Nothing as well. I leave a couple of screenshots.

Thank you!

What about the browsers devbeloper tools? Have you checked from console what is the exact query that goes to Firebase? Then test the query e.g. in Firebase admin panel to see whats causing the problem.

I checked the Developer tools but as I am not an expert I don’t know if I am in the right path or looked in the right place. In the console tab I saw this:

** error creating firebase query object from ‘where(“categories”,“array-contains-any”,"“Principiante”")’: FirebaseError: Invalid Query. A non-empty array is required for ‘array-contains-any’ filters.

Also, when I pick a value with no explicit quotation marks it shows:

** error creating firebase query object from ‘where(“categories”,“array-contains-any”,“Fácil”)’: FirebaseError: Invalid Query. A non-empty array is required for ‘array-contains-any’ filters.

So the issue seems not to be the quotation marks but that it says that the array is empty? The field “categories” does have arrays in all elements. Not sure if that is the problem or how to solve it.

This is how it works on my project. I’m simply adding ’ marks to picker value to make it work.

I finally got it working! Thank you so much for guiding me through it. It wasn’t an issue with the quotation marks but the brackets in the data slot field. After some trials this is the query that worked:


Now I am going to add the “All” category to get what I want and try to incorporate additional filters but I believe I know how to do it know that I found my problem.

Thank you!

1 Like