Firestore + cloud functions: How to read from another document

前端 未结 1 1813
粉色の甜心
粉色の甜心 2020-12-18 23:44

I\'m trying to write a Google cloud function that reads from another document. (Other document = not the document that triggered the cloud function.)

It\'s a bit of

相关标签:
1条回答
  • 2020-12-19 00:10

    Thank you, @frank-van-puffelen.

    This is the working solution:

    exports.updateLikeCount = functions.firestore
        .document('likes/{likeId}').onWrite((event) => {
            return admin.firestore()
                .collection('ruleSets')
                .doc(1234)
                .get()
                .then(doc => {
                    console.log('Got rule: ' + doc.data().name);
                });
        });
    
    0 讨论(0)
提交回复
热议问题