Reputation: 5559
I want to find set times for a particular artist.
I have a list of Artists
artistRef = FIRDatabase.database().reference(withPath: "artists")
I have a list of Sets (times)
showRef = FIRDatabase.database().reference(withPath: "sets")
I want to get all artist 1 set times: [set1, set3]
The following snapshot is returned as null:
showRef.queryEqual(toValue: artist?.key, childKey: "artistKey").observeSingleEvent(of: .value, with: { snapshot in
...
})
Is there anything that I'm doing obviously wrong?
Upvotes: 0
Views: 707
Reputation: 72410
Try to use queryOrdered(byChild:)
before the queryEqual(toValue:)
, like this.
showRef.queryOrdered(byChild: "artistKey").queryEqual(toValue: artist?.key).observeSingleEvent(of: .value, with: { snapshot in
for set in snapshot.children {
print("\((set as! FIRDataSnapshot).value)")
}
})
Upvotes: 4