Firebase queryEqual(toValue: [英] Firebase queryEqual(toValue:
本文介绍了Firebase queryEqual(toValue:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试快速使用queryEqual(toValue:.我遇到的问题是我变得空了.
I am trying to using the queryEqual(toValue: in swift. The issue I'm having is that I am getting null.
我的数据看起来像这样
"time" : {
"149791341619654" : {
"URL_ID" : "02D03DA8-A652-4EFA-946F-1F0F2A963449",
"UUID" : "F496B98E-3B4E-4602-B06D-C09B7F42DCB5",
"date" : 1.497913416196546E9,
"huer" : 0,
"latitude" : 32.87926715336076,
"longitude" : -117.2139702738423,
"type_" : "Image",
"uid" : "BjN8usKaW7NhqD2DxPPqAkjhnSx2"
},
"149791381894099" : {
"URL_ID" : "AB8D20E9-D1EB-4FD0-B0A8-CE755D1D8B91",
"UUID" : "F534E1FC-DC55-4AFB-847D-64B614EF7137",
"date" : 1.497913818940991E9,
"huer" : 0,
"latitude" : 32.87926715336076,
"longitude" : -117.2139702738423,
"type_" : "Image",
"uid" : "BjN8usKaW7NhqD2DxPPqAkjhnSx2"
},
"149791881234864" : {
"URL_ID" : "A3207072-FC64-4A09-87C0-E1340051B140",
"UUID" : "D0C3FA34-2790-4896-96F7-E0E7C3E17687",
"date" : 1.497918812348642E9,
"huer" : 0,
"latitude" : 32.87915823052905,
"longitude" : -117.2140478064466,
"type_" : "Video",
"uid" : "BjN8usKaW7NhqD2DxPPqAkjhnSx2"
}
}
例如,我希望只能获得孩子"149791381894099". 我当前正在使用的快速代码是(很抱歉,格式化表现很奇怪)
I want to be able get only the child "149791381894099" for example. The code in swift I am currently using is (sorry the formatting was acting weird)
self.rootRef.child(uidOtherProfile).child("time").queryEqual(toValue: 149791381894099).observeSingleEvent(of: .value, with: { (snapshot) in})
但是我用过
self.rootRef.child(uidOtherProfile).child("time").queryEqual(toValue: "149791381894099").observeSingleEvent(of: .value, with: { (snapshot) in
推荐答案
Firebase的默认排序顺序是优先的.要查询键,您需要调用queryOrderedByKey()
:
The default sort order for Firebase is by priority. To query the keys you need to call queryOrderedByKey()
:
ref.queryOrderedByKey().queryEqual(toValue: "149791381894099").observe(.childAdded, with: { (snapshot) in
print(snapshot)
})
这篇关于Firebase queryEqual(toValue:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文