I'm building a social network very similar to Twitter, in which users can see a feed with content posted by users they follow. Users can like and re-post (i.e. "Retweet") posts. Re-posted content works just like it does on Twitter. If a user re-posts a post, it will get shown to their followers.
My database is mongo db. Posts go into a posts collection. But I'm wondering about the best way to include a re-post so that it gets queried along with the posts for the feed query. I've thought about doing it several ways:
- Insert a re-post doc in posts docs collection, but add a field referencing the clip being re-posted. Not sure whether to repeat the re-posted post's data here.
- Use a separate collection for re-posts. Query both the posts and re-posts collections when retrieving the feed.
- Don't insert a re-post doc at all. Include a sub-document in the post's document that includes the re-poster info. When querying for the feed, use re-posters as part of the criteria. Problem is, the application will have no way to know if the post was selected bc the user follows the author or a re-poster, or which reposter.
Not sure what the best practice is for this. Advice is much appreciated.