代码之家  ›  专栏  ›  技术社区  ›  niclas_4

Firestore函数触发器不会触发

  •  0
  • niclas_4  · 技术社区  · 6 年前

    由于某些原因,onWrite事件没有在Firestore中触发。

    Img

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

    例如,将文档添加到 posts/postidblabla/comments/commentidblabla 不会触发函数。

    1 回复  |  直到 6 年前
        1
  •  1
  •   Renaud Tarnec    6 年前

    如果我没有弄错,这是因为你正在使用 async 云函数。

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

    onWrite() 需要两个参数,请参见 https://firebase.google.com/docs/functions/beta-v1-diff#realtime-database