gpt4 book ai didi

java - 在 Cloud Firestore 上创建或删除字段时如何获得通知

转载 作者:行者123 更新时间:2023-11-30 10:01:38 29 4
gpt4 key购买 nike

我在顶层有 3 个集合:TherapyUsersTransactionenter image description here

Users 下有CustomerTherapist。客户将与选定的治疗师创建一个交易

当客户订购东西时,会创建该字段,并且治疗师会收到通知。治疗师和客户都可以取消交易,这会将字段标记为已删除。删除后,两者都会收到通知。

我该怎么做?

我无法提供示例代码,因为我不知道从哪里开始。

最佳答案

Cloud Firestore triggers 提供处理 Firestore 事件的机制。

With Cloud Functions, you can handle events in Cloud Firestore with no need to update client code. You can make Cloud Firestore changes via the DocumentSnapshot interface or via the Admin SDK.

In a typical lifecycle, a Cloud Firestore function does the following:

  1. Waits for changes to a particular document.
  2. Triggers when an event occurs and performs its tasks (see What can I do with Cloud Functions? for examples of use cases).
  3. Receives a data object that contains a snapshot of the data stored in the specified document. For onWrite or onUpdate events, the data object contains two snapshots that represent the data state before and after the triggering event.

关于java - 在 Cloud Firestore 上创建或删除字段时如何获得通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57341885/

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