When i add a new document to firestore and listen for the snapshot changed, every documentchangeaction that is returned has "added" as type, as opposed to the just the newly added document.
Version info
Angular: ~11.2.0
Firebase: ^7.0 || ^8.0
AngularFire: ^6.1.5
Other (e.g. Ionic/Cordova, Node, browser, operating system):ionic: 6.13.1
When i add a new document to firestore and listen for the snapshot changed, every documentchangeaction that is returned has "added" as type, as opposed to the just the newly added document.
Version info
Angular: ~11.2.0
Firebase: ^7.0 || ^8.0
AngularFire: ^6.1.5
Other (e.g. Ionic/Cordova, Node, browser, operating system): ionic: 6.13.1
How to reproduce these conditions
Some samples of my code
this is inside of my firbease service
customerCollectionsAddedListener(){ try { return this.firestore.collection("Customers").snapshotChanges(); } catch (error) { throw error; } }
async createCustomerDocument(customer: Customer): Promise {
try {('Customers')
.add(JSON.parse(JSON.stringify(customer)));
} catch (error) {
throw error;
}
}
this.firestore .collection
this.firebase.customerCollectionsAddedListener().subscribe(value => { value.forEach(action =>{ var payload = action.payload; console.log(action.type); console.log(payload.type) ; if(action.type === "added" && payload.doc.metadata.fromCache){ console.log(payload.doc.id); console.log(payload.doc.data()); } }); });
Debug output
Expected behavior
The expected behavior is that only the newly added document has the type of added.
Actual behavior
The actual behavior is that all the documents have a type of added.