Bullwinkle
Bullwinkle

Reputation: 359

query firebase database by ordering two values in iOS swift

I have a database of posts in firebase, and each has a timestamp and a rating. i know how to order by time OR by rating, but would it be possible to order by rating, then limit by time. ie. show highest rated posts over the last week?

ie.

Ref.queryOrderedByChild("rating").observeSingleEventOfType(.Value, withBlock: {...}

would order by rating, but how would i then limit the query by time, and not rating?

Upvotes: 0

Views: 462

Answers (1)

Julian Lee
Julian Lee

Reputation: 263

Unfortunately, Firebase does not support cross referencing nor server-side logic, so you'll probably have to query by the more specific value, pull the data down, then sort the rest client side.

Alternatively, you could also try to get creative with GeoFire (firebase's cross referencing solution for latitude/longitude location querying), though that'll the hackiest solution ever...

Upvotes: 1

Related Questions