I am working a twitter like follow model, for which my User's schema is as follows.
var UserSchema = new Schema({
username: {type: String, match: /^[a-zA-Z0-9_]+$/, unique: true},
email: { type: String, unique: true },
password: String,
followings : [{ type: ObjectId, ref: 'User' }],
followers : [{ type: ObjectId, ref: 'User' }] });
I need to store just the user's ObjectId in the followings and followers field.
I am not sure how to Insert and Update the followings and followers collection. I tried with "Update" but it overwrites each time. Then tried push, but doesn't help.
Please help me.
Thanks in advance.