【发布时间】:2020-09-01 10:49:03
【问题描述】:
我有一个 firebase 云函数,它应该在创建新文档时增加字段的值。该函数成功执行,我可以在 firebase 日志中看到这一点,但它不会增加字段的值。
exports.onFileAdded = functions.firestore.document("files/{id}").onCreate(async (change, context) => {
const file = change.data();
const hub = await getByCollectionAndId('hubs', file.hubId);
Firebase.firestore().collection('teams').doc(hub.teamId).set({tileCount: Firebase.database.ServerValue.increment(1)}, {merge: true});
});
由于没有错误,并且函数执行成功,我做错了什么?
【问题讨论】:
-
“似乎没有做任何事情”有点棘手。您是否看到该函数是否在 Cloud Functions 日志中被调用?如果不是,那么 Functions 代码在调试中不会有太大用处,因为它没有运行,你会想看看你是如何触发这个代码的——所以你的 Firestore 的写操作应用程序。
-
抱歉,我已经重新措辞了我的问题
标签: node.js firebase google-cloud-firestore google-cloud-functions