I am trying to make a search function that queries user by their username from Firebase database, but I want my the function to only return the users with the exact username(letters) that is typed in to the search bar. so lets say if I type Mike into the search bar and tap search, I don't want it to return anything unless there is a user with this exact username(Mike).
I would really appreciate any help to improve my search function from you guys, thanks!
Here is my function:
var REF_USERS = Database.database().reference().child("users") func searchQueryUsers(text: String, completion: @escaping (theUsers) -> Void) { REF_USERS.queryOrdered(byChild: "username").queryStarting(atValue: text).observeSingleEvent(of: .value, with: { snapshot in snapshot.children.forEach({ (sss) in let child = sss as! DataSnapshot if let dict = child.value as? [String: Any] { let user = theUsers.setUser(dict: dict, key: child.key) completion(user) } }) }) }