【发布时间】:2021-03-06 08:33:03
【问题描述】:
这是从 Firebase 的文档中复制的:- https://firebase.google.com/docs/firestore/extend-with-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) => {
// If we set `/users/marie/incoming_messages/134` to {body: "Hello"} then
// context.params.userId == "marie";
// context.params.messageCollectionId == "incoming_messages";
// context.params.messageId == "134";
// ... and ...
// change.after.data() == {body: "Hello"}
});index.js
【问题讨论】:
标签: google-cloud-firestore google-cloud-functions