应用发布后更新Firestore中的数据路径 [英] Updating path of data in Firestore after app is released

查看:79
本文介绍了应用发布后更新Firestore中的数据路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我计划如何在Firestore中构造数据以针对用例进行优化时,我不禁要问,如果将来我需要更新Firestore中数据的路径会发生什么情况?

As I plan for how to structure my data in Firestore to optimize for my use-case, I can't help but wonder what would happen if in the future I need to update the path of my data in Firestore?

我是否需要实施某种机制来通知我的移动应用程序的所有旧版本停止启动并需要升级?还是在应用启动时进行安全检查,以读取Firestore中的位置来确定客户端是否需要升级或可以继续使用当前版本?

Will I need to implement some mechanism of notifying all older versions of my mobile app to stop starting and require upgrades? Or a safety check when the app starts that reads a location in Firestore to decide whether the client needs to upgrade or can continue using the current version?

似乎应该在客户端代码中对数据路径进行硬编码,这可能会带来风险,尤其是当Firestore中的数据结构复杂(子集合等)时产品的改进

It seems like paths to data are supposed to be hardcoded in the client code, which can pose risk, especially for improvements in the product when data structure in Firestore is complicated (subcollections, etc)

在Firestore中,有没有办法更好地计划此类灾难?

Is there a way to better plan for this kind of a disaster in Firestore?

推荐答案

第一个目标应该是使任何数据库更改都向后兼容.可能比您现在想的要多得多.

The first goal should be to make any database changes backwards compatible. It's possible a lot more often than you may think now.

但是,如果您真的想为不兼容的更改做准备,则应在数据库中包含一个版本号.在Cloud Firestore中,通常会将其放在已知文档名称的全局集合中,例如/Globals/VersionNumber .请注意,这是数据模型的版本号,不一定是应用程序的版本号.

But if you really want to prepare for incompatible changes you should include a version number in your database. In Cloud Firestore you'd typically put that in a global collection in a known document name, such as /Globals/VersionNumber. Note that this is the version number of the data model, not necessarily the version number of the app.

现在,当应用启动时,它将首先读取该文档,并检查版本号是否与它的用途匹配.如果不是,请告诉用户进行升级.否则,照常继续.

Now when the app starts, it reads that document first and checks if the version number matches with what it was made for. If it doesn't, tell the user to upgrade. Otherwise continue as usual.

这篇关于应用发布后更新Firestore中的数据路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆