我正在使用Firebase作爲我的應用的後端。我的應用程序將是某種費用跟蹤器。我想我應該重組我的數據,以便我可以輕鬆過濾日期的方式就是這樣。我的firebase數據庫結構會影響加載速度嗎?
UID /費用/分類/年/月/日/唯一鍵/細節
挖到快照會是這樣的
func retrieveData(){
_ = dataRef.observeEventType(.ChildAdded, withBlock: { (snapshotOne) in
if let snapshotTwo = snapshotOne.children.allObjects as? [FIRDataSnapshot] {
if let snapshotThree = snapshotTwo.children.allObjects as? [FIRDataSnapshot] {
if let snapshotFour = snapshotThree.children.allObjects as? [FIRDataSnapshot] {
for item in snapshotFour {
//retrieve details
}
}
}
}
}
}
我不知道什麼樣的後果是有深入挖掘數據庫以及我的數據庫結構是否正常?任何人都可以建議嗎?
的〔火力地堡文檔建議針對嵌套數據](https://firebase.google.com/docs/database/android/structure-data#avoid_nesting_data),由於各種原因。但像這樣循環快照很好。 '.ChildAdded'加載'snapshotOne','snapshotTwo','snapshotThree'和'snapshotFour'的所有數據。 –