如何在Firebase iOS上进行浅层查询?

我想在没有下载整个树的情况下计算我的数据库中有多少个对象。 我在REST api中找到了shallow属性。 我如何在iOS框架中使用它?

我的代码:

 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)) } 

您可以使用FDataSnapshot类,然后查询childrenCount属性。

FDataSnapshot文档

childrenCount参考