Mongoose virtuals
Jan 1, 2026
MongoDB virtuals are computed fields that are not stored in the database. They are calculated when data is fetched, keeping schemas clean and efficient.
Get Danushanthi Konesalingam’s stories in your inbox
Join Medium for free to get updates from this writer.
userSchema.virtual(‘fullName’).get(function () {
return `${this.firstName} ${this.lastName}`;
});
Virtuals reduce redundancy and always stay up to date



