有什么可以简化这个吗?
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)
})
我希望查询和搜索类似的颜色十六进制代码,然后获取整个数组,因此我的数据库的安排必须如下:
最佳答案
试试这个:-
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/