Reputation: 63
i have 3 tables [users, tracks, trackLikers]. when user like a track it added to trackLikers like this.
tracklikers
703486
AXweXLKIQiQYmwia5TbvNbSLk472: Alex
AXweXLKIQiQYmwia5TbvNbSLk472: John
704875
AXweXLKIQiQYmwia5TbvNbSLk472: Alex
Now i want to get how many tracks "Alex" likes. So i do it like this.
dbReference.child("tracklikers").orderByChild("AXweXLKIQiQYmwia5TbvNbSLk472").equalTo("Alex")
.
Ok fine i got the result of 2 tracks id [703486, 704875]. But the problem is i also got the John in 703486 result. So if i could have one million likes on this track i will have to retrive all likers :-(. So any one have solution how to solve this problem. Or only i can get the track id without all likers values ?
if there is no solution so unfortunately i have to switch to relational database :-(.
Upvotes: 0
Views: 398
Reputation: 15543
You should have another node such as user-tracks
to keep tracks which are liked by user.
user-tracks
- AXweXLKIQiQYmwia5TbvNbSLk472 // userId
- 703486 // track which user liked
Upvotes: 1