首页 > 解决方案 > 所有写入操作的 Firebase 函数

问题描述

所以我的问题是:对我的应用程序中的所有写入操作使用 Cloud Functions 是否不好,我是否错过了这种方法的缺点?

标签: androidfirebasegoogle-cloud-firestoregoogle-cloud-functions

解决方案


将 Cloud Functions 用于我的应用程序中的所有写入操作是否很糟糕?

从定义上讲,这还不错,但从定义上讲也不好。这完全取决于您的用例和实现。

有几点需要考虑:

  • 您的数据修改器的安全规则现在基本上已编码在您的 Cloud Functions 中。所以您的云功能安全了吗?您确定只有授权用户才能呼叫他们吗?

  • 您是否考虑让您的客户将他们的“关注此用户”请求写入 Cloud Firestore 中的特殊“客户请求”集合?您可以让 Cloud Functions 监控对该集合的写入,这有其优势。

  • For example: since the clients write to Firestore in this scenario, their write operations will not fail when they're offline, but instead be sent to the server (and processed there) when they're back online. In your current scenario you'd have to implement such retry-logic yourself.


推荐阅读