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

The*_*Ben 4 firebase google-cloud-firestore

Firebase 函数是否可以通过subcollections函数侦听顶级文档时的更改触发?如果不是,文档通配符示例中的第一行是什么意思?

这是什么意思???如果子集合更改会触发该功能吗?但它似乎没有,同一页面中的其他地方也这么说。

// Listen for changes in all documents and all sub-collections
Run Code Online (Sandbox Code Playgroud)

...

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"}
  });
Run Code Online (Sandbox Code Playgroud)

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

Dou*_*son 12

我相信示例代码中的注释对于文档通配符是这样的示例是不正确的:

'users/{userId}'
Run Code Online (Sandbox Code Playgroud)

请注意,在该示例下方的文本中,它表示:

如果 users 中的文档具有子集合,并且这些子集合之一的文档中的字段发生更改,则不会 触发userId 通配符。

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

'users/{userId}/{messageCollectionId}/{messageId}'
Run Code Online (Sandbox Code Playgroud)

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

随意为您认为不正确的文档或示例提交错误报告