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(); 
    firebase.database.ref('Users/' + uid).once(event => { 
    const snapshot = event.data; 
    const name = snapshot.child('name').val(); 
    }); 
}); 

イベントは別のノードによってトリガーされ、firebaseデータベースの別のノードからデータを取得します。上記のコードを試しましたが、TypeError:firebase.database.ref(...)というエラーが生成されます。onceは関数ではありません。クラウドファンクションのfirebaseデータベースでノードの値を取得する方法

+1

を使用することができます答えを得たが、あなたはその正確なエラーメッセージについてよろしいですか? 'firebase.database.ref()。once'を意味しますか?もしそうなら、 'firebase'とは​​何ですか?他のどこかで定義しましたか? –

答えて

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(); 
    }); 
}); 
関連する問題