Is there a way to version objects in Firebase that are meant to be read-only?

后端 未结 2 1396
别那么骄傲
别那么骄傲 2020-12-15 13:35

I am working on an app that will be cross-platform: web, android, iOS. I have a couple objects that are intended to specify some constants, like valid states. For example:

2条回答
  •  太阳男子
    2020-12-15 14:13

    Assuming you have an old app v1.0 and a new one v2.0, you have 50 clients reading/writing as per v1.0 and 50 clients reading/writing as per v2.0.

    The only question is if those groups of clients interact with each other or not?

    If no, they are happy with their app.

    If yes, v2.0 clients have to read data from v1.0 fields and upgrade it to v2.0 fields (default or with additional data from v2.0 clients) and while writing write v1.0 fields and then write additional v2.0 fields.

    The theory applies to one client interacting with multiple other version clients.

    Since firebase is schemaless, you can have two nodes of same category containing different number of fields, without problem. Hence with firebase, you should only take care that you won’t change the meaning of a field between the versions. In the newer versions, always keep the old read/writes as it is and for the new data always create new fields.

    Minimum required fields for a version to function must always be present in all higher versions of your product.

提交回复
热议问题