简体   繁体   English

Firestore 和更改应用程序中的文档模型

[英]Firestore and Changing Document Models in an App

So we have an app that interacts directly with Firestore.所以我们有一个直接与 Firestore 交互的应用程序。 In both queries for documents, creates new documents, updates, listens for changes, etc.在文档的两个查询中,创建新文档、更新、侦听更改等。

So we have one version of our app live.所以我们有一个版本的应用程序。 The question becomes how we can modify the model in the database, for example, adding a non-optional field, without breaking the functionality of the current apps that are installed on people's phones.问题变成了我们如何修改数据库中的 model,例如,添加一个非可选字段,而不破坏当前安装在人们手机上的应用程序的功能。

All I can think of for now is to require to be on the latest version, or perhaps the latest without a breaking change, in order to log in to initialize firebase - by using a major.minor.patch, and update the major whenever there's a breaking change.我现在所能想到的就是要求使用最新版本,或者可能是没有重大更改的最新版本,以便登录以初始化 firebase - 通过使用major.minor.patch,并在有任何时候更新主要版本一个突破性的变化。

Is there a smoother way to do this?有没有更流畅的方法来做到这一点? I am more familiar with the backend and web, so not sure what's considered a best practice in this case.我更熟悉后端和 web,所以不确定在这种情况下什么是最佳实践。

The simplest solution I can think of would be to add the version of the app into a document in the database, and each time you open the app, check that value against the one in the app's code.我能想到的最简单的解决方案是将应用程序的版本添加到数据库中的文档中,并且每次打开应用程序时,都要根据应用程序代码中的值检查该值。 If there is a match, it means that no update is required, otherwise, "force" the user to update the app to the latest version by opening the app's page from Google Play .如果匹配,则意味着不需要更新,否则,“强制”用户通过从Google Play打开应用程序页面将应用程序更新到最新版本。

Another solution might also be to use Android In-app updates :另一个解决方案也可能是使用Android 应用内更新

When your users keep your app up to date on their devices, they can try new features, as well as benefit from performance improvements and bug fixes.当您的用户在他们的设备上使您的应用程序保持最新时,他们可以尝试新功能,并从性能改进和错误修复中受益。 Although some users enable background updates when their device is connected to an unmetered connection, other users might need to be reminded to install updates.尽管一些用户在他们的设备连接到未计量连接时启用了后台更新,但可能需要提醒其他用户安装更新。 In-app updates are a Play Core library feature that prompts active users to update your app.应用内更新是一项 Play Core 库功能,可提示活跃用户更新您的应用。

So it's up to you to decide which one is better.因此,由您决定哪个更好。 Please note, that if you'll use the first one, you'll have to pay for a document read, each time a user opens the app.请注意,如果您使用第一个,则每次用户打开应用程序时,您都必须为阅读文档付费。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM