constructor(
private afs: AngularFirestore,
) {}
dbAdd(){
this.afs.collection()
this.afs.firestore.collection()
}
What is the difference between these two (this.afs.collection() & this.afs.firestore.collection()) ? And when to use each of them? Because during transaction and batch we have to use this.db_cloud.firestore.collection() and while reading data use this.db_cloud.collection()
Basically what happens is that AngularFire2 does not support Transactions natively, so it has to rely on the underlying framework to do it, which is what this.afs.firestore does - it calls the Firestore SDK to make the transaction for it.
So when should you use this.afs.firestore? Whenever you have to do something that is not natively implemented in AngularFire but that exists in the official SDK. Transactions and Batches are an example of that.
For reference you can check this GitHub issue thread where the implementation of that feature for AngularFire is discussed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With