With this code I can read and update single document in the transaction.
// Update likes in post
var docRef = admin
.firestore()
.collection(\"posts\")
.do
You can use batch to accomplish what you want.
var batch = db.batch();
var docRef = admin
.firestore()
.collection("posts")
.doc(doc_id);
var likes = ... // get the amount of likes
batch.update(docRef, { likes })
var profileRef = admin
.firestore()
.collection('profile')
.doc(profId)
batch.update(profileRef, { likes })
batch.commit() // at this point everything works or not
.then(() => {
console.log('success!')
})
.catch(err => {
console.log('something went wrong')
})