Luis F.
Luis F.

Reputation: 1360

Firestore How to make a transaction without read operations?

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

Answers (1)

Frank van Puffelen
Frank van Puffelen

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

Related Questions