我需要在两个不同的集合上触发我的函数。这该怎么做?
我有这样的东西,但第二个函数首先覆盖,第一个不起作用。这该怎么做?
'使用严格'; const functions = require('firebase-functions');const admin = require('firebase-admin');admin.initializeApp(functions.config().firebase); const 数据库 = admin.database();
exports.apptTrigger = functions.firestore
.document('notification/{anydocument}' )
.onCreate((snap, context) => {
const title = snap.data().title;
const messageis = snap.data().content;
const postId = snap.data().idPost;
const payLoad = {
notification:{
title: title,
body: messageis,
sound: "default"
}
};
return admin.messaging().sendToTopic("notification", payLoad);
});
exports.apptTrigger = functions.firestore
.document('notificationP/{anydocument}')
.onCreate((snap, context) => {
const title = snap.data().title;
const messageis = snap.data().content;
const postId = snap.data().idPost;
const payLoad = {
notification:{
title: title,
body: messageis,
sound: "default"
}
};
return admin.messaging().sendToTopic("notification", payLoad);
});```
郎朗坤
相关分类