【发布时间】:2018-03-28 04:19:17
【问题描述】:
我正在尝试使用 Firebase 函数实现触发器,该触发器会复制数据库中的一些数据。我想在votes/user/vote观看所有添加,结构是:
我试过的代码是:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.duplicateFeedback = functions.database.ref('/votes/{userId}/voteId')
.onWrite(event => {
const userId = event.params.userId;
const voteId = event.data.key();
const vote = event.data.val();
console.log(`New feedback from user ${userId}: { description: "${vote.feedback}", score: ${vote.rating}}`);
return;
});
但我什至无法触发它。任何线索我的功能有什么问题?我打赌与参考有关,但我无法弄清楚到底是什么。
【问题讨论】:
标签: javascript firebase firebase-realtime-database google-cloud-functions