I'm kinda new to firebase & react-native but I need a little help with a query I have to do for my project.
So let's say I have 2 tables
Posts:{postID(key), posterID, description}
Likes:{likeID(key), postID, likerID}
so the relationship between these two tables is on postID
Is there a way to count all likes for each Post and return top 10 with most likes? I know that this process can't be all on server side so I'm fine with any solutions really.
I think this is the query to count likes for one post:
firebase.database().ref(`/likes`)
.orderByChild('postId').equalTo(postID)
.once('value', snapshot => {
const likesCount = snapshot.count;
})