由于某些原因,onWrite事件没有在Firestore中触发。
exports.newCommentCounter = functions.region('europe-west1').database.ref('posts/{PostID}/comments/{CommentID}').onWrite(async(change) => {
例如,将文档添加到 posts/postidblabla/comments/commentidblabla 不会触发函数。
posts/postidblabla/comments/commentidblabla
如果我没有弄错,这是因为你正在使用 async 云函数。
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
onWrite()