Please support transaction API
https://www.firebase.com/docs/web/api/firebase/transaction.html
My guess is that it should be on FirebaseObjectObservable.transaction
For Firestore Transactions, the process is similar:
import { FirebaseApp } from 'angularfire2';
...
export class QuestionComponent implements OnInit {
questionRef;
constructor(private fb: FirebaseApp) {}
ngOnInit() {
this.questionRef = this.fb.firestore().collection('questions').doc(this.id);
}
voteYes() {
this.fb.firestore().runTransaction(transaction => {
return transaction.get(this.questionRef).then(question => {
const newVotes = question.data().yesVotes + 1;
transaction.update(this.questionRef, { yesVotes: newVotes });
});
});
}
@markgoho I was just wondering about this, and you commented less than an hour ago. Very cool fo you and coincidental.
@markgoho @aaronfrost Would you two be interested in an observable form of this API?
vs Promise based... why not. Not a huge pain to deal with a promise here.
@davideast I would love to see something observable based!
I should PR this to the documentation. It's sad that it's buried all the way over here in this 18 month old closed issue.
Can anyone take a look at https://stackoverflow.com/questions/50215622/firebase-database-transaction-with-angularfire2 ? I can't get this to work.