2

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))
        }
Oscar Apeland
  • 6,422
  • 7
  • 44
  • 92
  • 1
    That function doesn't exist.. Yet. Here's the solution [child count](http://stackoverflow.com/questions/15148803/in-firebase-is-there-a-way-to-get-the-number-of-children-of-a-node-without-load) – Jay May 09 '16 at 00:00

1 Answers1

0

You can use FDataSnapshot class and then query for the childrenCount property.

FDataSnapshot Docs

childrenCount Reference

funador
  • 554
  • 4
  • 8