nandorojo / swr-firestore

Implement Vercel's useSWR for querying Firestore in React/React Native/Expo apps. 👩‍🚒🔥
MIT License
777 stars 65 forks source link

How to overcome the array-contain's 10 max limit #139

Open rodbs opened 2 years ago

rodbs commented 2 years ago

To overcome the array-contain's 10 max limit, would it be possible to implement a kind of pagination?

My uses case is that I want to pre-filter the collection before doing an actual filtering. I have a 'items' collection, and each user has myFavItems. I want each user to do be able to filter the 'items' collection but only for his/her items. Example: For user A, it has 20 entries in his myFavItems. I want to go against the 'items' collection and filter by 'blue' items, but only within the scope of his 20 items.

So ideally I'd like to do something like:

 const myFavItems = [ 1,2, ... 20] 

 const { data  } = useCollection(    'items',
    {
      where: ['id', 'in', myFavItems ]
      where: ['color', 'array-contains', myColor],

    },

The problem is the first filter is limited to 10.

So, any ideas? What about to create a moving window to query for 10 items each time?

Thanks!