exports.respublished =
functions.database.ref('/Posts/{postid}').onWrite(event => {
const snapshot = event.data;
const postid = event.params.examid;
const uid = snapshot.child('uid').val();
const ispublic = snapshot.child('Public').val();
firebase.database.ref('Users/' + uid).once(event => {
const snapshot = event.data;
const name = snapshot.child('name').val();
});
});
该事件由另一个节点触发,我想从firebase数据库的另一个节点中检索数据。我已经尝试了上面的代码,但它产生了一个错误,说明TypeError:firebase.database.ref(...)。一次不是函数。
答案 0 :(得分:0)
是的,我得到了我们可以使用此代码的答案
exports.respublished = functions.database.ref('/Posts/{postid}').onWrite(event => {
const snapshot = event.data;
const postid = event.params.examid;
const uid = snapshot.child('uid').val();
const ispublic = snapshot.child('Public').val();
return admin.database().ref('Users/' + uid).once(event => {
const snapshot = event.data;
const name = snapshot.child('name').val();
});
});