While working with Node.js, Mongoose and MongoDB, I have found that my Mongoose schema getters and setters do not fire when I perform a findOne query.
I have found an ol
Try
schema.virtual('password').get(function () { return this.username; });
as your getter function, this is your entity instance and the value parameter doesn't mean much here.
this
value
If you were writing a setter function, you would have to write this.username = value.
this.username = value