Firestore Function Trigger wont trigger

时间:2019-01-09 22:31:34

标签: javascript firebase google-cloud-functions

For some reason the onWrite Event is not triggering in Firestore.

Img

Here you see the look of the function in the Firebase Website. Here is the trigger inside of my function ts file:

exports.newCommentCounter = functions.region('europe-west1').database.ref('posts/{PostID}/comments/{CommentID}').onWrite(async(change) => {

The logs are empty like the function never got triggered.

For example adding a Document to posts/postidblabla/comments/commentidblabla wont trigger the function.

1 个答案:

答案 0 :(得分:1)

如果我没有记错的话,这是因为您在Node.js 6 Cloud Function中使用了async

以下方法应该起作用:

exports.newCommentCounter = functions.region('europe-west1').database.ref('posts/{PostID}/comments/{CommentID}').onWrite((change, context) => {
 => {})

另外,请注意,由于v 1.0,onWrite()具有两个参数,请参见https://firebase.google.com/docs/functions/beta-v1-diff#realtime-database

因此,除了上述建议的更改外,请再次检查您是否拥有Firebase SDK for Cloud Functions的最新版本。