0

I want to fetch my firebase data based on two Childs "category and city" I've tried to make it like this but it didn't work

 let refPlace = Database.database().reference().child("places").queryOrdered(byChild: "category").queryEqual(toValue: catId).queryOrdered(byChild: "city").queryEqual(toValue: cityId)

is there a way to query based on those 2 variables ?

and I also want to know if there is other way than queryEqual and queryStarting that I can use for search, if I wanna search for a child named "one two three" by typing "two" is that possible?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Sophie Bernard
  • 197
  • 3
  • 13
  • 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 example, you could create a property `"category_city": "mycategory_mycity"` and then search on that. 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 Jun 30 '18 at 15:23
  • Firebase Database can only query for strings *starting* with a certain value. If you need more comprehensive text searching, you'll need to use a dedicated full-text search service. See https://stackoverflow.com/questions/22506531/how-to-perform-sql-like-operation-on-firebase and https://stackoverflow.com/questions/33867185/searching-in-firebase-without-server-side-code – Frank van Puffelen Jun 30 '18 at 15:26

0 Answers0