I'm building social network application with Firebase and Swift. I have user who have some followings to another users. I want to parse a feed for this user that contains posts only from his list of followings. My database looks like this:
"posts": {
"postA": {
"title": "Title for post A"
"byUser": "userABC"
}
}
"postB": {
"title": "Title for post B"
"byUser": "userCBA"
}
}
"postC": {
"title": "Title for post C"
"byUser": "userBCA"
}
}
"postD": {
"title": "Title for post D"
"byUser": "userBCD"
}
}
}
"users": {
"userABC": {
"name": "John"
"following": {
"userCBA": "true"
"userBCA": "true"
}
}
"userCBA": {...}
"userBCA": {...}
"userBCD": {...}
}
So the idea is to show filtered posts for userABC for his list of followings (postB & postC). What Firebase request I should make?
P.S.: the only idea I have is to make several firebase requests for each user to download their posts, then to append those into an array and then order array objects by timestamp. But imagine thousand of followings and each have a thousand of posts.. It will be a disaster.
P.P.S.: I can't fiter result by Firebase "Security & Rules" because I want to show all posts by all users in search.
Thanks a lot!