【发布时间】:2020-12-22 10:54:44
【问题描述】:
我知道这个问题已经被问过了,但它没有帮助。 我有一个“聊天”集合,其中包含一个文档“成员”和一个子集合“消息”,我想在子集合中添加新消息时触发云功能。
这是我尝试过的,但它仅在“成员”更新时触发,并且没有关于子集合的任何信息:
exports.chatsCollectionTriggers = functions.firestore.document('/chats/{chatId}/messages/{messageId}').onUpdate(async (change, context) => {
let chatBefore = change.before.data();
let chatAfter = change.after.data();
console.log(JSON.stringify(chatBefore, null, 2));
console.log(JSON.stringify(chatAfter, null, 2));
console.log(context.params.chatId);
console.log(context.params.messageId);});
我的问题是如何在子集合更新时触发云功能?
【问题讨论】:
标签: javascript node.js firebase google-cloud-firestore google-cloud-functions