gpt4 book ai didi

firebase - 子集合中的更改是否应该触发 onWrite 函数?

转载 作者:行者123 更新时间:2023-12-02 06:29:22 26 4
gpt4 key购买 nike

当函数正在监听顶级文档时,子集合中的更改是否可以触发 Firebase 函数?如果不是, documentation 的通配符示例中的第一行是什么?意思是?

这是什么意思???如果子集合发生变化会触发该函数吗?但似乎并非如此,同一页面的其他地方也这么说。

// 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"}
});

Firestore 和函数触发器的预期行为是什么

最佳答案

我认为示例代码中的注释对于文档通配符如下的示例是不正确的:

'users/{userId}'

请注意,在该示例下面的文本中显示:

If a document in users has subcollections, and a field in one of those subcollections' documents is changed, the userId wildcard is not triggered.

下面的示例带有以下通配符:

'users/{userId}/{messageCollectionId}/{messageId}'

仅当 users 中的任何文档子集合中的文档被写入时才会触发(而不是直接在 users 中的文档)。

欢迎联系file a bug report您认为不正确的文档或示例。

关于firebase - 子集合中的更改是否应该触发 onWrite 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48700080/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com