Can Firebase functions be triggered by a change in subcollections
when the function is listening to a top level document? If not, what does the first line in the wildcard examples of the documentation mean?
What does this mean??? if a sub-collection changes would it trigger the function? But it doesn't seem to and somewhere else in the same page says that too.
// Listen for changes in all documents and all sub-collections
...
exports.useWildcard = functions.firestore
.document('users/{userId}')
.onWrite((event) => {
// If we set `/users/marie` to {name: "marie"} then
event.params.userId == "marie"
// ... and ...
event.data.data() == {name: "Marie"}
});
What is the intended behavior for Firestore and function triggers?
I believe the comment in the sample code is incorrect for the sample whose document wildcard is this:
'users/{userId}'
Note that in the text below that sample it says:
If a document in users has subcollections, and a field in one of those subcollections' documents is changed, the userId wildcard is not triggered.
The sample below it with the following wildcards:
'users/{userId}/{messageCollectionId}/{messageId}'
will be triggered only when documents in any subcollection of documents in users
are written (not the documents immediately within users
).
Feel free to file a bug report for documentation or sample that you've for to be incorrect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With