Reputation: 1360
I want to set two documents inside a transaction using the javascript API. I tried the following:
db.runTransaction(function(transaction) {
return transaction.set(doc1Ref, doc1).set(doc2Ref, doc2);
})
But this isn't valid, I get the following error:
Uncaught (in promise) Error: Transaction callback must return a Promise
Upvotes: 0
Views: 198
Reputation: 598718
By definition transactions in Firestore are updates to the data based on an existing value. What you're looking for is not a transaction, but a batched write.
Upvotes: 1