Technologies:
Tolerim
3 hours ago
How can I monitor modifications to a document and its sub-collections in Firebase Cloud Functions?
// Listen for changes in all documents in the 'users' collection and all subcollections
exports.useMultipleWildcards = functions.firestore
.document('users/{userId}/{messageCollectionId}/{messageId}')
.onWrite((change, context) => {
});
export const generateAllBooks = functions.firestore
.document('books/{bookId}/{variantsCollectionId}/{variantId}')
.onWrite(async (change, context) => {});
Answers(1)
Tolerim
3 hours ago
Verified Answer
The code you provided is listening for changes in all documents in the 'books' collection and all subcollections, so it should trigger when a doc is changed in either the parent collection or any subcollection.
If it's not triggering for changes in the parent collection, make sure that there are actually changes happening in the parent collection and that your function is deployed and active. You can also check the Firebase Function logs to see if there are any errors or if the function is successfully running.