javascript - 触发器中使用通配符时部署云函数失败
问题描述
我正在尝试部署一个云功能,该功能将在将文档添加到特定集合时触发,如下所示:
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) => {});
但是,这会引发部署失败错误:
未能配置触发器提供程序/cloud.firestore/eventTypes/document.create@firestore.googleapis.com ( gcf .us-central1.checkCapacity)
如果我删除通配符并将引用更改为:
"gran_canaria/las_palmas_1/miller_pendientes/albnum"
我尝试将方法更改为 onWrite(),删除并重新部署该函数并在https://status.cloud.google.com/检查云状态,但找不到任何解决方案。
解决方案
我已经能够在我的 Cloud Firestore 上成功部署一个带有 onCreate 事件触发器的 Cloud Function。
在使用以下内容创建云时,我通过暗示在控制台 UI 中使用提供的模板取得了成功:
使用的 index.js 是 GCP 在创建函数时提供的示例,它只是打印到日志中哪个文档触发了更改。
查看 Firestore 中的文档,我发现您可能使用了那里提供的示例,因此使用上述设置可能会使其适合您。
推荐阅读
- javascript - 如何将html div复制到另一个div而不显示无div
- intellij-idea - 什么是更好的格式化工具:Intellij Code Style 或 Prettier
- sql-server - SqlBeginTransaction 并等待交付
- macos - 更新 Visual Studio for Mac 以测试 beta iOS 13 版本
- react-native - 使用多个视图反应本机导航根问题
- verilog - 在实例化的 Verilog 模块 (Yosys/CVC) 中动态检查建立/保持时间违规
- reactjs - 如何使用React(this.state)实现用户输入自动保存
- python - 用二维数组写入变量会导致它改变数组的值
- mongodb - 如何在 rust 中将 MongoDB 与 r2d2 和 actix 一起使用
- c# - 具有 SQL 参数的级联组合框