0

I am trying to run the below Stream, but this returns all the documents, completely ignoring the whereNotIn operator in Firebase Firestore.

FirebaseFirestore.instance
.collection('announcements')
.where("announcementReaders",
  whereNotIn: [
 "VAJDWALLfHQUKbOFTqz3JW2GhHC2"
]).snapshots(),

This is the structure of my database enter image description here

I was expecting it to not return this document, since it's announcementReaders array contains the ID I am explicitly searching to not return, but it shows it anyway.

I have eliminated other minor issues, such as spelling mistakes, index creation, ui mishaps, etc. I have this query in a StreamBuilder, and when I replace the query without a whereNotIn, it gives me the same result, implying that it is ignoring the whereNotIn operator. This issue also happens with arrayContains, where even if the announcementReaders array contains the ID, it will ignore it.

  • The `whereNotIn` operator cannot be used to check whether an array does **not** a certain value. Your condition instead checks whether the `announcementReaders` field as a whole is not equal to `"VAJDWALLfHQUKbOFTqz3JW2GhHC2"`, which it isn't. See https://stackoverflow.com/questions/59595938/firestore-possible-to-query-by-array-not-contains – Frank van Puffelen Mar 25 '23 at 18:43

0 Answers0