ios - Firebase 查询数组

标签 ios swift firebase firebase-realtime-database

有什么可以简化这个吗?

databaseRef.child("palettes").queryOrdered(byChild: "0").queryEqual(toValue: text).observeSingleEvent(of: .value, with: { (snapshot) in

    print (snapshot)

})

databaseRef.child("palettes").queryOrdered(byChild: "1").queryEqual(toValue: text).observeSingleEvent(of: .value, with: { (snapshot) in

    print (snapshot)

})

databaseRef.child("palettes").queryOrdered(byChild: "2").queryEqual(toValue: text).observeSingleEvent(of: .value, with: { (snapshot) in

    print (snapshot)

})

databaseRef.child("palettes").queryOrdered(byChild: "3").queryEqual(toValue: text).observeSingleEvent(of: .value, with: { (snapshot) in

    print (snapshot)

})

databaseRef.child("palettes").queryOrdered(byChild: "4").queryEqual(toValue: text).observeSingleEvent(of: .value, with: { (snapshot) in

    print (snapshot)

})

我希望查询和搜索类似的颜色十六进制代码,然后获取整个数组,因此我的数据库的安排必须如下:

enter image description here

最佳答案

试试这个:-

 FIRDatabase.database().reference().child("palletes").queryOrderedByKey().queryStarting(atValue: "0").queryEnding(atValue: "5").observeSingleEvent(of: .value, with: {(snap) in

    print(snap)

    })

关于ios - Firebase 查询数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39762431/

相关文章:

javascript - alert() 在 WKWebview 中不起作用 evaluateJavaScript()

ios - 一个应用程序可以使用 startMonitoringForRegion 注册多少个 UUID?

ios - 从 Parse 中检索信息

ios - 寻找可扩展的 TableView 来转换我的 JSON 树结构

ios - 将 UIImage 从 ImagePicker 解包到 Firebase.Storage 时致命

ios - 如果节点具有 currentuser.uid 对象并显示在我的 UITableViewCell 中,则从 Firebase 中的节点检索对象

ios - 在 ios 上刷新 JWT 身份验证 token

ios - 无法获取用户列表

java - Android studio/Firebase - 遇到无限循环试图获取数据

ios - 测试因 faSTLane 错误而失败