Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularFirebase transaction and batch writes?

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()

like image 457
Shubhendu Avatar asked Aug 05 '26 06:08

Shubhendu


1 Answers

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.

like image 134
Ralemos Avatar answered Aug 07 '26 21:08

Ralemos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!