【发布时间】:2020-03-09 11:01:22
【问题描述】:
我遇到了一个独特的用例,以下功能将非常有用。
本质上,我的组件正在监听document 中的特定更改,我的安全规则设置为允许读取,但所有写入都被禁用,因为数据库更新只能通过云功能进行,因此我正在研究文档以查找是否可以执行此类操作。
/**
* This update should only happen locally / offline in order to update state of components
* that are listening to changes in this document
*/
myDocumentRef.update({ name: 'newname' });
/**
* Then cloud function is called that performs validation and if correct
* updates document with new data (same as one we set offline above).
* Once that is done listening components will receive new data. If unsuccessful
* we would set document to old data (again offline) and show error.
*/
await myCloudFunction();
因此我的问题是:是否可以在本地/离线执行更新(并且仅更新)? 这基本上是利用 firebase 作为全球存储的“乐观更新”流程。
【问题讨论】:
-
您可以创建自己的策略。这个答案stackoverflow.com/questions/47843218/…。
标签: firebase google-cloud-firestore google-cloud-functions