Updating the user model

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.

Get Full-Stack React Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.