For some reason the onWrite Event is not triggering in Firestore.
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.
答案 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的最新版本。