I've had already implemented a function to search for users using the FirebaseDatabase
like that:
REF_USERS.queryOrdered(byChild: "username_lowercase").queryEnding(atValue: text+"\u{f8ff}").queryLimited(toFirst: 25).queryStarting(atValue: text).observeSingleEvent(of: .value, with:
{
(snapshot) in
snapshot.children.forEach(
{
(s) in
let child = s as! DataSnapshot
if let dict = child.value as? [String: Any]
{
let user = UserInfo.createUser(dict: dict, key: child.key)
if user.id! != currentUserId
{
completion(user)
}
}
})
})
But now I've decided to switch from the Database
to Firestore
and since they've been bragging about their great querying I figured it shouldn't be too hard but for a few days now I've been trying to figure out how to search for users and can't seem to get it done.
Thats the code I have so far:
REF_USERS.order(by: "username_lowercased").limit(to: 25).order(by: text).getDocuments
{
(snapshot, error) in
snapshot?.documents.forEach(
{
(s) in
let child = s
let user = UserInfo.createUser(dict: child.data(), key: child.documentID)
if user.id! != currentUserId
{
completion(user)
}
})
}
But like i said nothing really works.
Any suggestions? Id really appreciate it c:
-Marie