Вам не нужно вызывать once
внутри функции, поскольку она уже возвращает данные в месте, которое вы слушаете, просто прослушайте родительский узел.
Так что вы должны сделать, как:
exports.onNotificationUpdate = functions.database.ref('/Notification/{userId}/{notificationId}').onUpdate(event => {
const notification = event.data.val();
if (notification === null) {
console.error("Notification not found on notification update");
return null;
//actually this would only be called in case of deletion of the Notification
} else {
//do something with the notification data: send Android notification, send mail, write in another node of the database, etc.
//BUT return a Promise
//notification const declared above is a JavaScript object containing what is under this node (i.e. a similar structure than your database structure as shown in the image within your post.)
}
});
Я бы посоветовал вам взглянуть на эти три видео от команды Firebase:
https://www.youtube.com/watch?v=7IkUgCLr5oA&t=517s
https://www.youtube.com/watch?v=652XeeKNHSk&t=27s
https://www.youtube.com/watch?v=d9GrysWH1Lc
Также обратите внимание, что облачные функции были обновлены, и первая строка вашего кода должна быть написана иначе, если вы используете версию CF выше 1.0.0. Смотри https://firebase.google.com/docs/functions/beta-v1-diff