0

I want to make a query on my firebase database. I want all my "sheets" ordered on starsCountvalue for making a ranking. But i also want just the sheetsof a specified category ( Where classe child value equals 01UXe0rm78CrLiynLUQw for exemple )

My datas :

This is a sheet child

This is my code :

let ref = Database.database().reference().child("sheets").queryOrdered(byChild: "starsCount").queryEqual(toValue: 01UXe0rm78CrLiynLUQw, childKey: "classe").queryLimited(toLast: 15)
        ref.observeSingleEvent(of: .value) { (snapshot) in
            guard let values = snapshot.value as? NSDictionary else {
                return
            }
            ...

And i have a console message :

2017-12-13 20:35:43.219165+0100 Notee[500:118222] [Firebase/Database][I-RDB034028] Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ".indexOn": "starsCount" at /sheets to your security rules for better performance

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Mathis Delaunay
  • 172
  • 1
  • 16
  • What's your question? – Frank van Puffelen Dec 13 '17 at 20:00
  • I know how to make a query which provides me the sheets ordered on starsCount (queryOrderer), i know how to make a query which provides me the sheets with a specified category ( queryEquals ) , but noth it's doesn't work and i don't know why – Mathis Delaunay Dec 13 '17 at 20:27
  • Firebase Database queries can only order/filter on a single property. In many cases it is possible to combine the values you want to filter on into a single (synthetic) property. For an example of this and other approaches, see my answer here: http://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase – Frank van Puffelen Dec 13 '17 at 20:51
  • Okay fine, thanks for your help, i will do your first approache, i don't have many entities to sort. – Mathis Delaunay Dec 13 '17 at 21:19

0 Answers0