Process Flow - In and not-in queries
Start Query
Check Query Type
in query
Match docs
Return docs
End
The query starts by checking if it is an 'in' or 'not-in' query, then matches or excludes documents accordingly, and finally returns the results.
db.collection('users') .where('status', 'in', ['active', 'pending']) .get() .then(snapshot => { // process docs })
| Step | Query Type | Field | Operator | Values | Action | Result |
|---|---|---|---|---|---|---|
| 1 | in | status | in | ['active', 'pending'] | Check each doc's status | Match docs with status 'active' or 'pending' |
| 2 | in | status | in | ['active', 'pending'] | Collect matched docs | Docs with status 'active' or 'pending' collected |
| 3 | not-in | status | not-in | ['inactive', 'banned'] | Check each doc's status | Exclude docs with status 'inactive' or 'banned' |
| 4 | not-in | status | not-in | ['inactive', 'banned'] | Collect remaining docs | Docs without status 'inactive' or 'banned' collected |
| 5 | end | - | - | - | Return final docs | Query complete, results returned |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | After Step 4 | Final |
|---|---|---|---|---|---|---|
| matchedDocs | [] | ['doc1', 'doc3'] | ['doc1', 'doc3'] | - | - | ['doc1', 'doc3'] |
| excludedDocs | [] | - | - | ['doc2', 'doc4'] | ['doc2', 'doc4'] | ['doc2', 'doc4'] |
| finalDocs | [] | - | - | - | - | ['doc1', 'doc3'] or ['doc1', 'doc3', 'doc5'] depending on query |
Firebase 'in' and 'not-in' queries filter documents by matching or excluding specific field values. Use 'in' to get docs with any value in a list. Use 'not-in' to exclude docs with values in a list. Only one 'in' or 'not-in' filter per query is allowed. Results are returned after filtering documents accordingly.