Javascript Firestore功能触发器不会触发

Javascript Firestore功能触发器不会触发,javascript,firebase,google-cloud-functions,Javascript,Firebase,Google Cloud Functions,由于某些原因,Firestore中未触发onWrite事件 在这里,您可以看到Firebase网站中函数的外观。以下是我的函数ts文件中的触发器: exports.newCommentCounter = functions.region('europe-west1').database.ref('posts/{PostID}/comments/{CommentID}').onWrite(async(change) => { 日志是空的,就像函数从未被触发一样 例如,将文档添加到post

由于某些原因,Firestore中未触发onWrite事件

在这里,您可以看到Firebase网站中函数的外观。以下是我的函数ts文件中的触发器:

exports.newCommentCounter = functions.region('europe-west1').database.ref('posts/{PostID}/comments/{CommentID}').onWrite(async(change) => {
日志是空的,就像函数从未被触发一样


例如,将文档添加到
posts/postdballa/comments/commentidballa
不会触发该函数

如果我没有弄错的话,这是因为您在Node.js6云函数中使用了
async

以下方面应起作用:

exports.newCommentCounter = functions.region('europe-west1').database.ref('posts/{PostID}/comments/{CommentID}').onWrite((change, context) => {
 => {})
另外,请注意,由于v1.0,
onWrite()
接受两个参数,请参阅


因此,除了上面建议的更改外,请仔细检查您是否有最新版本的Firebase SDK用于云功能。

我发现了这个问题,因为我使用了.database.ref而不是.firestore.document,我刚刚弄糟了这部分,我很抱歉在这个愚蠢的错误上浪费了您的时间…问题找到了下面的检查注释