我正在用下面的代码构造一个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
...
}
该块被调用,但我想按每个Point中的另一个字段对结果进行排序。由于不可能将两个queryOrderedByChild
链接在一起,因此我将代码更改为以下代码(稍后我将链接排序查询)。
let ref = FIRDatabase.database().reference()
let pointRef = ref.child("points")
let query = pointRef.queryEqualToValue(locationName, childKey: "location")
query.observeSingleEventOfType(FIRDataEventType.ChildAdded, withBlock: { (snapshot) in
...
}
这里的块从未被调用过。为什么不行?我希望这些调用是相同的(除了第一个是按位置排序的)。
https://stackoverflow.com/questions/38220449
复制