作者:xi曦 | 来源:互联网 | 2023-05-18 08:45
ThisismyFirebasedatabasestructure:这是我的Firebase数据库结构:ft-recordsuserX@gmail_com2013-01
This is my Firebase database structure:
这是我的Firebase数据库结构:
ft-records
userX@gmail_com
2013-01-01 00:00:00 GMT
addedByUser: "userX@gmail.com"
notes: "Boooo"
time: "2013-01-01 00:00:00 GMT"
2013-01-02 10:00:00 GMT
addedByUser: "userX@gmail.com"
notes: "Yeaah"
time: "2013-01-02 10:00:00 GMT"
userY@gmail_com
2013-01-01 03:00:00 GMT
addedByUser: "userY@gmail.com"
notes: "Ok"
time: "2013-01-01 03:00:00 GMT"
I can query this data like this for the authenticated user e.g. userX@gmail_com
对于经过身份验证的用户,我可以像这样查询此数据,例如用户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 ... } )
But if I wanted to query all notes from all users for a specific date, how do I achieve this?
但是,如果我想查询所有用户在特定日期的所有笔记,我该如何实现?
I needed somehow a wildcard to read all children from root and then query by time of each child. But I'm not sure how to do that.
我需要一个通配符来从root读取所有孩子,然后按每个孩子的时间查询。但我不知道该怎么做。
Could I do something like this?
我可以这样做吗?
let ref = FIRDatabase.database().reference(withPath: "ft-records/*")
1 个解决方案