Search code examples
firebasegoogle-cloud-firestorewhere-clausewhere-in

Firestore how to do a multiple where clause


I have a question about querying with Firestore.

Indeed, I am developing a mobile application of the social network type with a feed of publications from its subscribers.

However, I can't find any solution using Firestore to view posts from all my subscriptions.

Currently, I have a collection "Users" (which contains a uid and my user information), "Publications" (which lists all the publications of the application) and a document with my list of uid to who I am subscriber.

I was thinking of doing a query like "Show all publications in the collection 'Publications' where uid = one of the uid in my array of uid and order by date.

However, I haven't found a solution to do it because the solution I found is to use the IN operator which is limited to 10 items, while I can have thousands of subscriptions.

ref.orderBy('date', 'desc').where('uid', 'in', arrayOfUid).get();

Do you have an idea ?


Solution

  • You can't exceed the limits of the "in" query. If you need more, you will have to perform multiple queries, and merge their results in the app. There are no workarounds to this.