Reputation: 871
Guys need some input creating a data structure that can be scaled for my use case.
I as a user can have many followers & can follow others too. So when I create a post my followers should get it. The Typical use case similar to Twitter or FB, but not so complex.
So for Instance I(Joseph) follow 2 users, hence my feed should be populated with the posts from the users I follow.
How can I fetch the posts of persons I follow. Or please guide on how to achieve the same using Firebase Realtime DB (NoSQL)
Upvotes: 1
Views: 1025
Reputation: 80914
{
"following":{
"josephid":{
"name" : "joseph"
"naber" : true
"roger" : true
}
}
"followposts":{
"pushid":{
"foriegnid": "pushid1"
"foriegnfollowid": "josephid"
}
"anotherpushid":{
"foriegnid": "pushid2"
"foriegnfollowid": "josephid"
}
}
}
Create another node that will take the ids
in the node post
and the id
of the current user. That way the people that person is following and the posts are connected with each other. The Foriegnid
and foriegnfollowid
is just a name not an id but the value is the pushids of the posts and the userid
Upvotes: 1