spf2 / FirebaseAdapter

Swift UI toolkit that makes building scalable Firebase UIKit applications easier.
MIT License
9 stars 0 forks source link

Building queries #2

Closed staticdreams closed 8 years ago

staticdreams commented 8 years ago

Hi!

I really like the adapter, by so far it has been limited to simple use, such retrieving all the record I have. How would I got about creating more complex queries?

For instance I need to get all records in my news collection where 'published' == true Or only view news created by a particular user? or even a currently logged in user?

Thanks for this wonderful Firebase adapter :)

spf2 commented 8 years ago

Hi,

I'm glad you're finding the adapter helpful. This section has some info on how to use the QueryBuilder. For something like published=true, you'd do something like query.ordering = .Child("published") and query.start = true. This just passes the query to the underlying Firebase protocol (look for Querying Data here).

If you want to do user-based querying, this kind of thing might work, but you may be better served by copying (denormalizing) your data. There's more about that here.

staticdreams commented 8 years ago

Thank you! It worked!)