Retrieve multiple filters in Firebase [Swift]

早过忘川 提交于 2021-02-05 11:17:36

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!