gpt4 book ai didi

ios - 如何在 Firebase 中使用通配符?

转载 作者:搜寻专家 更新时间:2023-10-30 22:19:17 24 4
gpt4 key购买 nike

这是我的 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"

我可以像这样为经过身份验证的用户查询此数据,例如userX@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/*")

最佳答案

您将为此使用 Firebase 数据库查询。

let ref = FIRDatabase.database().reference(withPath: "ft-records")
let query =ref.queryOrdered(byChild: "time").queryStarting(atValue: "2013-01-02 00:00:00 GMT").queryEnding(atValue: "2013-01-02 23:59:59 GMT")

有关详细信息,请参阅 Firebase documentation on filtering dataFirebase codelab for iOS .

关于ios - 如何在 Firebase 中使用通配符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42892819/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com