I have a User schema with followers array like below,
const userSchema = new mongoose.Schema({
firstname: {
type: String,
required: true,
},
lastname: {
type: String,
required: true,
},
followers: [{ type: ObjectId, ref: "User" }],
following: [{ type: ObjectId, ref: "User" }],
});
When i query for list of Users i need two extra fields isFollowing and isFollower
(isFollowing exists in my following array, isFollower exists in following array)