I'm following Firebase's recommendation of flattening data, but I'm having trouble listing a series of items from my database.

Here's a sample of my database file:

```
"users" : {
    "UID12349USER" : {
      "firstName" : "Jon",
      "lastName" : "Snow",
      "email" : "jonsnow@winterfell.com",
      "albums" : {
        "UID124ALBUM" : true,
        "UID125ALBUM" : true
      }
    }
},
"albums" : {
    "UID124ALBUM" : {
      "name" : "My Artwork",
    },
    "UID125ALBUM" : {
      "name" : "My Sketches",
    }
}

```

I'm retrieving the list of albums for a given user:

```
let userAlbums = database.child(usersKey).child(user.uid).child(albumsKey)
userAlbums.observeSingleEventOfType(.Value, withBlock: { snapshot in
    // fetch [UID124ALBUM: 1, UID125ALBUM: 1]
})

```

Now I wish I could retrieve all the user's albums in one single query.
I could do a batch of queries, and populate an asynchronous array, but that doesn't seem like a good approach to me...

```
for key in albumKeys {
    let album = database.child(self.albumsKey).child(key)
    album.observeSingleEventOfType(.Value, withBlock: { snapshot in
        // fetch album.. append to array
    })
}

```

Using that approach makes it tricky to detect when the queries have finished, due to the asynchronous nature of the requests. Add to that the fact that some of the requests might fail, due to a bad connection.

Also, if I want to filter one of the albums with a given name (e.g. "My Artwork") or return nil if it doesn't exist, I also end up with a tricky end condition.

```
var found = false

for key in albumKeys {
    let album = database.child(self.albumsKey).child(key)
    album.observeSingleEventOfType(.Value, withBlock: { snapshot in
        // if current.name == "My Artwork"
        // completion(current)
    })
}
// This block will be called before observeSingleEventOfType =.=
if !found {
    completion(nil)
}

```

I have a good background on iOS and Swift, but I'm knew to Firebase and NoSQL databases. Can someone point me a good direction? Should I ditch Firebase and try something else? Am I missing some method that can query what I need? Is my json structure wrong and missing some extra keys?

Thanks