angular / angular/angularfire

Firestore - collectionChanges function not emitting empty array when not elements present in queried collection

Open
#3,242 6 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
7.8k
Forks
2.2k
Avg merge
22h 28m
Merged PRs (30d)
6

Description

**Angular:**
13.3.11

**Firebase:**
9.8.4

**AngularFire:**
7.4.1

**Other (e.g. Ionic/Cordova, Node, browser, operating system):**
Node: 14.19.0
Maxc OS: 12.3.1
Chrome (latest)

### How to reproduce these conditions

`
const elements = [1,2,3];
`

`
const surveyReferencesQuery = query(
collection(
this.afs,
'surveyReferences'
) as CollectionReference,
where('companyId', 'in', elements)
);`

`
return collectionChanges(
surveyReferencesQuery
).pipe(
tap((c) =>
console.log(
'collectionChanges',
c.map((s) => [
s.type,
s.doc.id,
s.doc.data(),
])
)
)
);`

### Expected behavior

Should emit empty array

### Actual behavior

Not emitting anything until documents in collection

Contributor guide

Open the contributing guide

Research direction

Start at the collectionChanges entry point and reproduce the provided Firestore query with an empty surveyReferences collection. Compare the observable's initial behavior with the expected empty-array emission; done means the query emits an empty array before matching documents exist.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, firebase, typescript
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.