我应该使用哪种Firestore数据模型策略?

时间:2019-02-21 15:52:01

标签: google-cloud-firestore

我阅读了一些文档,但对该问题没有明确的答案。实际上,我有大约200个孩子的在职培训清单。相应的App android应用可用。

我的难题是,在第一个版本中,仅“ isSelected”已更改,但在第二个版本中,所有用户均再次创建。那不是一种应该避免的资源浪费吗?

如果您有实践经验,请告诉我哪种型号最合适。非常感谢!

模型1

>>Collection
  "users"             
        >>Document
          "Chuck_Norris"
               >>Data
                 uid: someuid             
                 username: Chuck Norris
                 profileImageUrl: chnoris.jpg
                                               >>Collection 
                                                "Training day" 
                                                    >>Document
                                                      "2019_02_21"
                                                                >>Data
                                                                  isSelected: false
                                                      "2019_02_22"
                                                            >>Data
                                                                isSelected: false
                                                      "2019_02_23"
                                                            >>Data
                                                                isSelected: false

或 模型2

>>Collection
    "Training day"

          >>Document
             "2019_02_21"     
                     >>Collection
                            "users"    
                                 >>Document
                                   "Chuck_Norris"
                                       >>Data
                                         uid: someuid             
                                         username: Chuck Norris
                                         profileImageUrl: chnoris.jpg
                                         isSelected: false

              >>Document
                 "2019_02_22"     
                         >>Collection
                                "users"    
                                     >>Document
                                       "Chuck_Norris"
                                           >>Data
                                             uid: someuid             
                                             username: Chuck Norris
                                             profileImageUrl: chnoris.jpg
                                             isSelected: true

              >>Document
                 "2019_02_23"     
                         >>Collection
                                "users"    
                                     >>Document
                                       "Chuck_Norris"
                                           >>Data
                                             uid: someuid             
                                             username: Chuck Norris
                                             profileImageUrl: chnoris.jpg
                                             isSelected: true

0 个答案:

没有答案