A few months back Firebase implemented promises in the database.
In that blog post there is an example of using a single transaction with promises:
var article;
var articleRef = ref.child('blogposts').child(id);
articleRef.once('value').then(function(snapshot) {
article = snapshot.val();
return articleRef.child('readCount').transaction(function(current) {
return (current || 0) + 1;
});
}).then(function(readCountTxn) {
renderBlog({
article: article,
readCount: readCountTxn.snapshot.val()
});
}, function(error) {
console.error(error);
});
Is it possible to chain multiple promises into a single transaction to be able to erase data only if everything can be erased?