Filter data by ANY condition (need some help)

Hey @Dimos_Vamvourellis, more info:

The first issue is a Firebase limitation – Firestore doesn’t have an id field we could use to filter the documents. It has a name property that contains the path to the document combined with the “id”, which is not a queryable document field like the other data fields.

The other issue is also related to how Firebase works, it requires you to set up indices manually for all fields you want to query. If you open up the Network tab in Chrome developer tools while in the web preview (right click on browser window → “Inspect”), you’ll be able to see the actual error message which is “The query requires an index” and a link to where you can create the index.

More info about the limitations here:
https://firebase.google.com/docs/firestore/query-data/order-limit-data#limitations
https://firebase.google.com/docs/firestore/query-data/queries#query_limitations

Hey @Mari even though i still get the same error message, i cant find the link i need to follow from firebase, could you help me?

Switch from Console to Network tab, the Firebase error should be there. :slight_smile:

Hey, really dont know if im doing something wrong, but i cant find the firebase link anywhere…
has anyone got more luck?

indeed after looking more closely i cant find the link anywhere. Do you know whats going on?
Thank you in advance

Hi there, If I am not mistaken what is @Mari trying to say is to open Developer Tab, select “Network” and then look for “event.json” (usually, but could be different).

Alternative is to try to call the same via the Postman. Usually Postman will tell you more than Appgyver do and to be honest, sometimes is better to use direct API calls as AppGyver is not 100% compatible with Firestore (for example, Firestore requires PATCH for update and Appgyver’s doing POST via Update Record) and there’s much more cases. So get yourself Postman, look for the endpoint you need and try it.

Ref: REST API базы данных Firebase
Ref: Cloud Firestore API  |  Firebase

Hi there, thanks for the response, this is what i get in the response,

even though as an error from firebase i get the Failed to map firestore query conditions.
i dont know why that error is not showing in the respone.
do you think i should look in postman?

Hi @Mari im sorry for tagging you, but unfortunately i haven’t still resolved my problem and i have looked everywhere for help. If you have any more knowledge on what’s going on, i would appreciate your help a lot.
So the problem, still remains that i cant find the firebase link to create the query filtering, even though i get the error message about mapping query conditions.

Hi @Dimos_Vamvourellis, sorry for the long follow-up time! What kind of query exactly is it that is giving you this error, is it the one with an ANY condition? Looks like Firebase has a limitation there:

https://firebase.google.com/docs/firestore/query-data/queries?hl=uk#query_limitations

Cloud Firestore provides limited support for logical OR queries. The in , and array-contains-any operators support a logical OR of up to 10 equality ( == ) or array-contains conditions on a single field. For other cases, create a separate query for each OR condition and merge the query results in your app.

Hey @Mari Thank you very much for your help, yes this is exactly what i was looking for, even though this feature is critical for my app, do you think, that this is possible maybe with separate calls for each product id with something like a loop, or you think for many documents we will need many calls and this might bring problems?
Also,
Do you know any other way in order to achieve the same result, meaning, to call many documents from a document id list ?

thank you in advance.

Hi, I posted one example of such a loop in this thread:

1 Like

Thank you so much i will take an extensive look!

Hey @Mari following your idea i did my own version where the logics are shown bellow and it works but with some lagging.


(the one thing that im not so sure if its optimized, is where i set the data variable by adding the new data to the old) bellow you can see the logics of the set data variable do you thing its optimal (for now you can see there are only 10 records but in the future there might be hundreds)?

I have one more question, if you can help me. More specifically as you can see in the video, it is clear that there is a loop (because of the way they appear on screen) and so i was wondering, if this is something that will also be noticeable in the final app, so the user can see them appearing one after the other, or in the final app everything happens faster and so this wont be so noticeable?

After all do you think there’s a way to minimize this ?

Thank you in advance.
I wanted to let you know that youve helped me so much with this.

Hi, you’re correct, the drawback of the loop method is that the requests are sent one after another, not in parallel, so the items will appear in the order in which they are added to the final collection. One solution to prevent the images appearing at different times is to use the Conditional Renderer component to display a spinner until the loop has finished fetching all the data, using for example a true/false page variable to indicate when loading is done.

Sending requests in parallel is also possible (so the whole operation only takes as long as the slowest request you send), but there isn’t currently a no-code solution for this. You can reach a more performant execution with the custom JavaScript node using the axios library (docs here), this article outlines how to use Promise.all() to achieve this.

i will check these out. But from what i understand, one disadvantage to this solution, is the order they appear, which for me is a plus because i need that order and the ‘big’ disadvantage is the loading time, which i can solve with your solution, but im thinking of doing it a bit different by making the loader invisible after loading 20 posts (or when finishing if the posts are less then 20) because these have to be shown first and there is no reason to wain until all are downloaded. Last of all im betting that the time needed in the actual app will be less noticeable, but i will definitely take a look at the other solution and if i can i will implement it.
Thank you very much!

I think I’m having a similar issue as this post. When I do the below filter to get a record collection using “AND” it works fine, but when I use “ANY”, I get an error.

Query:

Error:

Is it possible this is still an issue?

yeah, exactly, there are also some limitations concerning filtering Boolean variables

thanks for the reply. What limitations are there? Can I get around it if I use the REST API rather than the Firebase integration? From what I’ve seen the “ANY” doesn’t seem to work at all since the query I’m doing is fairly basic (2 equal conditions). But I’m relatively new to Appgyver so would be happy to learn I’m doing it wrong.

I may just resort to your loop solution above. Did you keep that in place in the end?

No unfortunately, you cant override the limitations with rest api, because the limitations are from firebase.
You can find more about the limitations, in firebase documentation.