May 2018
Intermediate to advanced
470 pages
13h 54m
English
To store the list of following and followers in the database, we will update the user model with two arrays of user references.
mern-social/server/models/user.model.js:
following: [{type: mongoose.Schema.ObjectId, ref: 'User'}],followers: [{type: mongoose.Schema.ObjectId, ref: 'User'}]
These references will point to the users in the collection being followed by or following the given user.
Read now
Unlock full access