我正在尝试使用CloudFi还原触发器调用一个云函数。基本上,每当一个新文档被添加到“评论”中时,我的云功能就是对我的子集合“评论”进行完整的导出。我有大约6-7个文件在我的‘评论’子收藏。我通过控制台部署了该函数,并完成了部署。但是,每当我向我的“评论”子集合添加一个新文档时,这个函数就不会被触发。谁能告诉我有什么问题吗?
providers/cloud.firestore/eventTypes/document.write触发器类型: Cloud (Beta) 事件类型:文档路径:test_/{reviews}

编辑:--我希望我的云功能只将添加到我的消防站的新文档导出到我的GCP桶中。下面是我试图编写的函数:
const functions = require('firebase-functions');
const firestore = require('@google-cloud/firestore');
const client = new firestore.v1.FirestoreAdminClient();
const bucket = 'gs://ABC/trigger_test'
exports.newFirestoreBackup = functions.firestore
.document('test_restaurant/{Id}/reviews/{Id}')
.onWrite((change, context) => {
const databaseName = client.databasePath(
// process.env.GCLOUD_PROJECT,
"FS-123",
'(default)'
);
return client
.exportDocuments({
name: databaseName,
outputUriPrefix: bucket,
// Leave collectionIds empty to export all collections
// or define a list of collection IDs:
// collectionIds: ['users', 'posts']
collectionIds: ['reviews'],
})
.then(responses => {
const response = responses[0];
console.log(`Operation Name: ${response['name']}`);
return response;
})
.catch(err => {
console.error(err);
});
});控制台片段:

发布于 2020-06-25 12:34:18
您不共享任何代码,但如果希望“每当向reviews子集合添加新文档时”触发云函数,则应使用以下路径声明该函数:
exports.createUser = functions.firestore
.document('test_restaurant/{restaurantId}/reviews/{reviewId}')
.onCreate((snap, context) => {...});您也可以使用具有相同路径的onWrite()触发器。
https://stackoverflow.com/questions/62571378
复制相似问题