如何在Firebase iOS上进行浅层查询? [英] How do I do a shallow query on Firebase iOS?
本文介绍了如何在Firebase iOS上进行浅层查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想统计我的数据库中有多少个对象,而无需下载整个树。我找到了 shallow
在REST API中的属性。我如何在iOS框架中使用它?
我的代码:
tripRef
.queryOrderedByChild 状态)
.queryEqualToValue(TripStatus.Unconfirmed.rawValue)
.queryLimitedToFirst(1000)
.shallow = true //这显然不起作用。
.observeSingleEventOfType(.Value){(snapshot:FDataSnapshot!)in
result(count:Int(snapshot.childrenCount))
}
解决方案
您可以使用FDataSnapshot类,然后查询childrenCount属性。
I want to count how many object I have in my database without downloading the whole tree. I found the shallow
property in the REST api. How can I use this in the iOS framework?
My code:
tripRef
.queryOrderedByChild("status")
.queryEqualToValue(TripStatus.Unconfirmed.rawValue)
.queryLimitedToFirst(1000)
.shallow = true //This does not work, obviously.
.observeSingleEventOfType(.Value) { (snapshot:FDataSnapshot!) in
result(count: Int(snapshot.childrenCount))
}
解决方案
You can use FDataSnapshot class and then query for the childrenCount property.
这篇关于如何在Firebase iOS上进行浅层查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文