I have an array of IDs. Now, I would like to fetch all documents that DO NOT exist in that array.
Lets say let array = ["id1", "id2", "id3];
let array = ["id1", "id2", "id3];
and document IDs in Firestore: "id1", "id2", "id3", "id4", "id5".
So basically I need to fetch only the docs with "id4" and "id5";
I thought of using this but I am not sure how exactly:
const westCoastCities = citiesRef.where('regions', 'array-contains', 'west_coast').get();
I am new to Firebase so please be patient with me.
This should work
idsRef.where('ids', 'not-in', ["id1", "id2", "id3]);
You should always check their doc first https://firebase.google.com/docs/firestore/query-data/queries#not-in
2.1m questions
2.1m answers
60 comments
57.0k users