1

I have a contact list:

[
"abc"
"def"
]

and chat records that have the following format

from :"dpasha52"
to: "jbabu"
text: "some message"
timestamp :1 September 2021 at 17:57:02 UTC+5:30

I need to query firebase collection such that

===========>not in takes contact list

this.angf.collection('Chats', ref => ref.where('from',not in, ["","",""]).where('to','==',this.userinfo.name))
               .valueChanges();

the only problem is not in only allows 10 entries.

is there any way to include more than 10 entries?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
dpasha52
  • 15
  • 5
  • This has been covered a few times already, so I recommend reading some of these: https://stackoverflow.com/search?q=%5Bgoogle-cloud-firestore%5D+query+more+than+10+%5Bjavascript%5D – Frank van Puffelen Sep 08 '21 at 14:07
  • @FrankvanPuffelen This issue HAS NOT BEEN COVERED. The "in" query is not the same as "not-in". The related issues are not related at all. – Frederiko Ribeiro Oct 21 '21 at 09:30

1 Answers1

1

the only problem is not in only allows 10 entries

Yes, that is correct, you can only perform a query up to 10 entries.

How do I query a firebase collection by the 'not in' parameter with more than 10 values?

If you have more than 10 entries, then you should consider retrieving the entries in batches, and then process the entries that are coming from each separate query either sequentially or in parallel.

Is there any way to include more than 10 entries?

No, currently there isn't.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
  • This solution will work but only for the "in" and not for the "not-in" query. The reason is that the not-in will ignore 10 items but for the next batch, it will not ignore the 10 items that has been previous ignored. – Frederiko Ribeiro Oct 21 '21 at 09:27
  • @FrederikoCesar That's entirely **not** true. It will work for both "in" and "not-in" queries. In other words, something that was previously ignored will be indeed ignored the second time, we perform a query. However, this is true only if the elements that exist within the second List satisfy that. If you have some references to the docs or even some code examples that support your hypothesis, feel free and post your own answer. You might also want to check [this](https://stackoverflow.com/questions/59257753/firebase-firestore-query-an-array-of-more-than-10-elements) out. – Alex Mamo Oct 21 '21 at 10:08
  • 1
    Sure, I removed the down-vote, but still by following the logic of retrieving in batches, there will be some problems. It's not the same as "in" because in the "not-in" you're ignoring and then when you move to the next query, it's impossible to Firebase to know that the previous query has items that you ignored, so the items ignored in the first query will appear in the second query and so on, for that you need some special treatment after each query, that could't be performatic. I wanted to post a solution or at least a better guide, but the issue is closed to post answers, unfortunately. – Frederiko Ribeiro Oct 22 '21 at 07:33