我有一個數據庫方案,它在本質上是相同的是,一個是documentation:如何獲得孩子的,其陣列中含有一定值
// An index to track Ada's memberships
{
"users": {
"alovelace": {
"name": "Ada Lovelace",
// Index Ada's groups in her profile
"groups": {
// the value here doesn't matter, just that the key exists
"techpioneers": true,
"womentechmakers": true
}
},
...
},
"groups": {
"techpioneers": {
"name": "Historical Tech Pioneers",
"members": {
"alovelace": true,
"ghopper": true,
"eclarke": true
}
},
...
}
}
我想創建一個DatabaseQuery
即得到所有用戶參加特定組(例如,其「組」包含「techpionneers」的用戶)
我應該如何繼續?我嘗試了Database.database().reference(withPath: "users").queryOrdered(byChild: "groups").queryEqual(toValue: "techpioneers")
,但這並不奏效(顯然)。
這是一個很好的答案,這樣我就不必做兩個查詢的一部分用戶。謝謝 –