5
這是我的火力地堡的數據庫結構:如何在Firebase中使用通配符?
ft-records
[email protected]_com
2013-01-01 00:00:00 GMT
addedByUser: "[email protected]"
notes: "Boooo"
time: "2013-01-01 00:00:00 GMT"
2013-01-02 10:00:00 GMT
addedByUser: "[email protected]"
notes: "Yeaah"
time: "2013-01-02 10:00:00 GMT"
[email protected]_com
2013-01-01 03:00:00 GMT
addedByUser: "[email protected]"
notes: "Ok"
time: "2013-01-01 03:00:00 GMT"
我可以例如查詢該數據像這樣通過認證的用戶用戶X @ gmail_com
let userRecords = self.ref.child(self.user.email.replacingOccurrences(of: ".", with: "_", options: .literal, range: nil))
userRecords.queryOrdered(byChild: "time").queryStarting(atValue: startOfDayDateString).queryEnding(atValue:endOfDayDateString).observe(FIRDataEventType.value, with: { snapshot in ... })
但是,如果我想查詢到所有用戶的所有筆記的具體日期,我該如何實現這一目標?
我需要一個通配符來讀取根目錄下的所有子項,然後按照每個子項的時間查詢。但我不知道該怎麼做。
我可以這樣做嗎?
let ref = FIRDatabase.database().reference(withPath: "ft-records/*")
我不明白。 'ft-records'的孩子是'userX @ gmail_com'和'userY @ gmail_com'。沒有'時間'來查詢。我錯過了什麼嗎? – Houman
對啊,這裏有一個額外的水平。您無法跨多個動態級別進行查詢。 –