How to write denormalized data in Firebase

前端 未结 2 701
名媛妹妹
名媛妹妹 2020-11-21 22:41

I\'ve read the Firebase docs on Stucturing Data. Data storage is cheap, but the user\'s time is not. We should optimize for get operations, and write in multiple places.

2条回答
  •  遥遥无期
    2020-11-21 23:28

    To add to Franks great reply, I implemented the eventual consistency approach with a set of Firebase Cloud Functions. The functions get triggered whenever a primary value (eg. users name) gets changed, and then propagate the changes to the denormalized fields.

    It is not as fast as a transaction, but for many cases it does not need to be.

提交回复
热议问题