Firestore Cloud Functions priority
Now I deploy two cloud functions in the Firestore database.
They are triggered by the same document changes.
Is it
There is no way to indicate relative priority between functions.
If you have a defined order you want them invoked in, use a single Cloud Function and just call two regular functions from there:
exports.onCommentWritten = functions.firestore
.document('post/{postId}/comments/{commentsID}')
.onWrite((change, context) => {
return Promise.all([
updateCommentNum,
writeUserLog
])
})
function updateCommentNum(change, context) {
//update the comment numbers in the post/{postId}/
}
function writeUserLog(change, context) {
//write the comment name,text,ID,timestamp etc. in the collection "commentlog"
}
That will also reduce the number of invocations, and thus reduce the cost of operating them.