I\'ve been struggling so much with this project. I am following a tutorial that is out of date in some areas, for instance their version of Jquery used a totally different f
Try below snippet I wanted to name _id as userId you can do without it as well.
var Schema = mongoose.Schema, ObjectId = Schema.ObjectId; var UserSchema = new Schema({ username: String, password: String }); UserSchema.virtual('userId').get(function(){ return this._id; });