Мне нужно активировать свои функции в двух разных коллекциях. Как это сделать?
У меня что-то подобное, но вторая функция перезаписывает первую, а первая не работает. Как это сделать?
'используйте строгий';const functions = require ('firebase-functions'); const admin = require ('firebase-admin'); admin.initializeApp (functions.config (). firebase);const database = 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);
});```