如何修改以下代码,以便功能仅在添加子项时触发 ?目前,只要指定的引用发生了变化,就会触发函数...
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.myFunction = functions.database.ref('/messaging/{pushId}')
.onWrite(event => {
//child is added. Do something!
});
答案 0 :(得分:3)
使用onCreate()处理程序代替onWrite()
。
exports.myFunction = functions.database.ref('/messaging/{pushId}')
.onCreate(event => {
//child is added. Do something!
});