Hi Sandeep, I read in a post on Hashnode that you guys use mongoDB as your primary database. Features like follows and feeds would require storing and querying heavily relational data. Assuming I have a users collection, what would be the best way to implement follows in mongoDB?
Sidhant Panda
Programmer
Sandeep Panda
co-founder, Hashnode
Hi Shiva!
For architecting "Follow/Following" system in MongoDB, your best bet is probably creating a junction collection (Many-Many table in relational DBs). For example, you could have a collection with documents that have the following schema:
{ from: { type: ObjectId }, // Indicates who's is following to: { type: ObjectId } , // Who's being followed dateAdded: 'Date', isActive: 'Boolean' }Or if you need a more sophisticated approach, use a graph database that gives you more freedom and flexibility. The only downside is that you will introduce another moving part into your app and you should have enough knowledge of the graph DB.
IMO, if you are just starting out go with MongoDB (assuming this is the DB of your choice), and once you hit any bottlenecks or limitations, start searching for other solutions.