问题
Is there a way to quickly pull all the userId that has the same username? For example, if userId_002 also had the username "sean", can I quickly retrieve ["userId_001","userId_002"]? I appreciate any help!
I'm trying this but doesn't work:
let results = Database.database().reference().child("usernames").queryOrdered(byChild: "username").queryEqual(toValue: "sean")
results.observeSingleEvent(of: .value, with: { (snapshot) in
for child in snapshot.children {
let value = child as! DataSnapshot
let key = value?["userId"] as? String ?? ""
self.array.append(key)
}
}
})
来源:https://stackoverflow.com/questions/65053999/retrieve-multiple-filters-in-firebase-swift