1

I'm trying to use 2 wildcards :

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

and getting the

"Error 3: The Request has errors".

However when using only 1 the function works normally:

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

Complete function code:

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 log:

[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": "Expected value establishments/{establishmentId}/payment/payments/{paymentId} to match regular expression [^/]+/[^/]+(/[^/]+/[^/]+)*" }] }] } } ⚠ functions: failed to update function projects/myProject/locations / us - central1 / functions / myFunction

Firestore:

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

1 Answer 1

4

Confirm that the path ends on a document and that it follows the pattern collection/document/collection/document/... I'd guess the path is supposed to be 'establishments/{establishmentId}/payments/{paymentId}'

Sign up to request clarification or add additional context in comments.

2 Comments

I have added how is the Firestore. So it can't end with paymentId once it's a map? Is there any way to get when update one specific payment?
Ah I understand your situation more fully now. Unfortunately, I do not know how to achieve what you're attempting. Best of luck, I'm eager to see the solution as well!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.