My use case:
UserA can create post.
Users B,C,D... can follow userA in order to see his posts on their screen.
My design idea:
/users --> registered users
/posts --> collection where users store their posts (in app I have screen that list all posts by date not related to following users so this is what everybody see).
/feed --> when post is created I copy here photo, title, short description and tags this documents has less data than posts.
In user document I have:
/users
-userId
- followers
-userIdB
-userIdC
-userIdD
- followings
Now when UserA create new post:
- it is stored in
/posts - it is copied with less info in
/feed - fetch list of
followersand copy with less info in/users/userB...C...D/feedcollection. - if
userIdEstarts to followuserAI copyuserAposts to/users/.../userIdE/feed
When I list posts from all I fetch data from /feed
When I list posts from users I follow I fetch from /users/myId/feed
Until this point I think that design is good (I hope).
This is proof of concept that real users will use but I am limited to my app I can't use firebase functions as client doesn't want to start with paid plan.
What could be a problem to make all this data copy to: feed, users/feed from user phone in terms of cost?
I am also scared that somebody can sit and follow/unfollow same user which will make coping data million times.