【发布时间】:2025-11-24 06:30:02
【问题描述】:
我正在使用以下代码构造一个FIRDatabaseQuery:
let ref = FIRDatabase.database().reference()
let pointRef = ref.child("points")
let query = pointRef.queryOrderedByChild("location").queryEqualToValue(locationName)
query.observeSingleEventOfType(FIRDataEventType.ChildAdded, withBlock: { (snapshot) in
...
}
块被调用,但我想按每个点中的另一个字段对我的结果进行排序。由于不可能将两个queryOrderedByChilds 链接在一起,我将代码更改为以下(稍后我将链接排序查询)。
let ref = FIRDatabase.database().reference()
let pointRef = ref.child("points")
let query = pointRef.queryEqualToValue(locationName, childKey: "location")
query.observeSingleEventOfType(FIRDataEventType.ChildAdded, withBlock: { (snapshot) in
...
}
这里的块永远不会被调用。为什么不?我希望这些调用是相同的(除了第一个按位置排序)。
【问题讨论】:
-
let query = pointRef.child("location").queryEqualToValue(locationName)
标签: ios swift firebase-realtime-database