Firestore模式版本控制以及与Android应用程序的向后兼容性以防止崩溃 [英] Firestore schema versioning and backward compatibility with android app to prevent crashes

查看:70
本文介绍了Firestore模式版本控制以及与Android应用程序的向后兼容性以防止崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Firestore NOSQL是面向文档的数据库.现在,当我将数据与Firebase SDK和Android应用程序一起使用时,如何管理数据的版本控制?

Firestore a NOSQL is a Document oriented database. Now how to manage versioning of the data as I use it with Firebase SDK and Android applications?

例如假设我有一个JSON模式,该模式是通过我的Android应用程序的1.0.0版本启动的.稍后的1.0.1版本出现了,我必须为新文档添加一些额外的字段.由于我将结构更改为具有其他信息,因此它仅适用于新文档.

For e.g. let's say I have a JSON schema that I launch with my 1.0.0version of my android app. Later 1.0.1 comes up where I have to add some extra fields for the newer documents. Since I changed the structure to have additional information, it only applies to new documents.

因此,使用此逻辑,我可以看到我的Android应用程序必须能够处理所有版本的JSON树,如果将其用于在Firebase控制台中使用Firestore创建的该项目.但这可能是非常痛苦的权利,我不断承担着向后兼容性的沉重负担吗?有没有办法在protobuf中提供某种版本,或者将android应用发送到Firestore服务器端,以便我们能够自动执行某些操作以防止在看到新字段时android应用崩溃?

Therefore, using this logic, I can see my Android application must be able to deal with all versions of JSON tree if used against this project I create in the firebase console with Firestore. But this can be very painful right, that I have carry the deadweight of backward compatibility endlessly? Is there a way to have some sort of version like in protobuf or something the android app can send to firestore server side so that automatically we can do something to prevent crashes on the android app when it sees new fields?

另请参见此主题,即工程师发布的问题.当android应用在JSON树中发现新字段时,您可能会遇到这种问题 添加新字段或更改所有Firestore上的结构文档

See also this thread, the kind of problem the engineer has posted. You can end up with this kind of problem as new fields get discovered in your JSON tree by the android app Add new field or change the structure on all Firestore documents

关于我们应该如何处理的任何建议?

Any suggestions for how we should go about this?

在node.js架构中,我们使用default-> v1.1/update或 default-> v1.0/update,这样我们就可以管理路由.

In node.js architecture we handle this with default-> v1.1/update or default-> v1.0/update, that way we can manage the routes.

但是对于与Firestore NOSQL对话的android + firebase SKD->,我如何管理json模式的版本控制.

But for android+firebase SKD-> talking to Firestore NOSQL, how do I manage the versioning of the json schema.

推荐答案

我们介绍了Firestore的下一个版本:

We come up to next versioning with Firestore:

  • 更喜欢添加剂变化,向后兼容->保持结构 照原样,但是添加了新字段(旧字段可以忽略) 移动客户端)
  • 以防万一,我们正在倒退 不兼容的更改:我们在Firestore中有一个名为版本"的集合,用于在其中存储具有允许版本的客户端.然后在午餐时间移动应用程序获取当前平台的该版本,并将配置中的版本与存储在Firestore中的版本进行比较-如果版本小于最小允许值,则需要强制升级,否则,如果版本小于当前版本,我们建议更新客户端,否则一切正常.
  • prefer additive changes, backward compatible -> keeping structure as it was, but with adding new fields (that can be ignored by old mobile clients)
  • in case it is impossible, and we are doing backward incompatible change: we have a collection in Firestore, called 'versioning', where store clients with allowed versions. Then mobile application on lunch fetch this version for current platform and compare version from configuration with stored in Firestore - if version is less then min allowed, force upgrade required, else if version less then current, we recommend updating the client, otherwise all is fine.

这篇关于Firestore模式版本控制以及与Android应用程序的向后兼容性以防止崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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