0
有没有一种方法来查询Firebase数据而不知道整个参考路径?我需要能够将数据从一个用户的配置文件转移到另一个基于解决方案编号的值。Firebase查询2级无深度参考快速
这里是我的数据结构
的图片,我将无法访问其他用户的UID,当我试图发送信息。有没有办法解决这个问题,或者我将不得不重构我的数据?
这是我当前的查询方法,我只是觉得在for循环可能是不好的做法
// MARK: - Search for trainees
func searchForTrainees() {
self.ref.child("users").observeSingleEventOfType(.Value, withBlock: { snapshot in
if snapshot.value! is NSNull {
} else {
if let users = snapshot.value! as? JSONDictionary {
for user in users {
let userUID = user.0
if let userInfo = user.1 as? JSONDictionary {
if let uplineSolutionNumber = userInfo["upline_solution_number"] as? String {
if uplineSolutionNumber == self.currentUser?.solution_number {
self.syncUserData(userUID)
}
}
}
}
}
}
})
}
如果有做更有效的方式这个请让我知道