首页 > 解决方案 > Firebase 函数部署:错误 3 - 请求有错误

问题描述

我正在尝试使用 2 wildcards

functions.firestore
    .document('establishments/{establishmentId}/payment/payments/{paymentId}')

并得到

“错误 3:请求有错误”。

但是,当仅使用 1 时,该功能正常工作:

functions.firestore
    .document('establishments/{establishmentId}')

完整的功能代码:

exports.myFunction = functions.firestore
    .document('establishments/{establishmentId}/payment/payments/{paymentId}')
    .onUpdate((change, context) => {
        return secondaryApp.firestore()
            .collection("myCollection").doc("myDocument")
            .update(change.after.data());
    })

--debug日志:

[2021 - 07 - 13T16: 35: 32.864Z] << < HTTP RESPONSE BODY { "error": { "code":400, "message": "The request has errors", "status": "INVALID_ARGUMENT", " details": [{ "@type": "type.googleapis.com/google.rpc.BadRequest", "fieldViolations": [{ "field": "event_trigger", "description": "预期值机构/{establishmentId} /payment/payments/{paymentId} 匹配正则表达式 [^/]+/[^/]+(/[^/]+/[^/]+)*" }] }] } } ⚠ 功能:未能更新功能项目/myProject/locations/us - central1/functions/myFunction

火库:

 - establishments: collection
   - {establishmentId}: document
     - payment: map
       - payments: array
         - {paymentId}: map

标签: javascriptnode.jsfirebasegoogle-cloud-firestoregoogle-cloud-functions

解决方案


确认路径在文档上结束并且它遵循collection/document/collection/document/...我猜路径应该是的模式'establishments/{establishmentId}/payments/{paymentId}'


推荐阅读