最佳答案
由于您可以“添加”但不能“更改”您的结构,因此一个选项是“添加”一个子节点,该子节点代表在该匹配节点下猜测的所有猜测者 uid。顺序或计数并不重要,因为我们只想返回匹配节点(match_id_1、match_id_2 等)
matches
match_id_1
TzEnmFC: true
Tss9S9i: true
T99a0ds: true
然后执行查询匹配是用户 uid = true
let queryRef = self.ref.child("matches")
let ref = queryRef.queryOrdered(byChild: "some_uid").queryEqual(toValue: true)
ref.observe(.value, with: { snapshot in
//do something with query results
})
关于swift - 基于 uid 交叉 randomKey 从 firebase 获取数据的好解决方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49183442/