How can I do batch writes/run transactions with firestore in an angular2 app?
https://firebase.google.com/docs/firestore/manage-data/transactions
If it's possible, how can I convert the JS code to TS code in an angular2 app.
How can I do batch writes/run transactions with firestore in an angular2 app?
https://firebase.google.com/docs/firestore/manage-data/transactions
If it's possible, how can I convert the JS code to TS code in an angular2 app.
It's simple:
If you are using AngularFirestore, firstly you will need to make sure that your constructor is setup as follows:
Now you can use db.firestore to get a firebase.firestore instance.
You can just copy the code from the link and replace db with db.firestore. Or you can make it more fancy using arrow functions:
Updating data with transactions:
Passing information out of transactions:
Batch writes: