【发布时间】:2019-05-19 21:23:53
【问题描述】:
我正在尝试使用以下方法监听子集合上的删除:
'use strict';
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
console.log('listen for delete');
exports.sendActivityChangeNotification = functions.database.ref('/games/{gameId}/attendees/{attdendeeId}')
.onDelete(async (change, context) => {
const gameId = context.params.gameId;
const attdendeeId = context.params.attdendeeId;
console.log(`activityId ${activityId} attdendeeId ${attdendeeId}` );
}
路径“/games/{gameId}/attendees/{attdendeeId}”的位置 games 是父集合 gameId 是文档,参加者是我要在删除文档时收听的集合。
这甚至可能吗?这是我第一次使用函数。我确实确保使用部署函数后存在的新数据进行测试。
感谢您的任何建议!
【问题讨论】:
标签: firebase firebase-realtime-database google-cloud-functions