在触发器中使用通配符时无法部署云功能 [英] Failure to Deploy Cloud Function When Using Wildcard in Trigger
问题描述
我正在尝试部署一个云功能,该功能将在将文档添加到特定集合中时触发,如下所示:
I'm trying to deploy a cloud function that will trigger whenever a document is added to a particular collection as below:
const admin = require("firebase-admin");
const functions = require("firebase-functions");
const Firestore = require("@google-cloud/firestore");
const firestore = new Firestore({ projectId: config.projectId });
admin.initializeApp(config);
exports.checkCapacity = functions.firestore.document("gran_canaria/las_palmas_1/miller_pendientes/{albnum}")
.onCreate(async (snapshot, context) => {});
但是这会引发部署失败"错误:
However this throws the Deployment failure error:
无法配置触发器提供程序/cloud.firestore/eventTypes/document.create@firestore.googleapis.com( gcf .us-central1.checkCapacity)
Failed to configure trigger providers/cloud.firestore/eventTypes/document.create@firestore.googleapis.com (gcf.us-central1.checkCapacity)
如果我删除通配符并将引用更改为:
The error clears if I remove the wildcard and change the reference to:
"gran_canaria/las_palmas_1/miller_pendientes/albnum"
我尝试将方法更改为onWrite(),删除并重新部署该函数,并在
I've attempted changing the method to onWrite(), deleting and re-deploying the function and checking the cloud status at https://status.cloud.google.com/ but can't find any solutions.
推荐答案
我能够在Cloud Firestore上的onCreate事件上成功部署带有触发器的Cloud Function.
I have been able to deploy successfully a Cloud Function with a trigger on an onCreate event on my Cloud Firestore.
通过以下方式创建云时,我隐含地在控制台UI中使用了提供的模板,从而获得了成功:
I have been successful by imply using the provided template in the Console UI when creating the Cloud with the following:
使用的index.js是GCP创建该函数时提供的示例,该示例仅将触发更改的文档打印到日志中.
The index.js used is the sample provided by GCP when created the function, which simply prints to the logs which document triggered the change.
查看Firestore中的文档,我发现您可能使用了在那里提供的示例,因此也许使用上面的设置将使其适合您.
Looking at the documentation in Firestore, I see that you probably used the samples provided there, so maybe using the above settings will make it work for you.
这篇关于在触发器中使用通配符时无法部署云功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!