santosh kc santosh kc - 5 months ago 455
Swift Question

Search all user by user's full name in firebase IOS

I have added

UISearchBar
and
UITableView
in my project. I need to filter all the users according to the text in
UISearchBar
and display in the tableview. I do research for the query in firebase documentation but I did not find. I just need the firebase query for partial string. Can any one help me?

Answer

I believe you have these in your firebase database

  • firstName
  • lastName

and firebase won't let you do multiple where clause, to solve this, just add a new field, so it will become like this

  • firstName
  • lastName
  • fullName


ref.child("users")
   .queryOrderedByChild("fullName")
   .queryEqualToValue("your full name")
   .observeSingleEventOfType(.Value, withBlock: { (snapshot) -> Void in

   }