How to add virtual function to Mongo Schema in NestJS

The title is a mouthful but it is what it is. Just wanted to drop a short memo.

I was trying to figure out how to get the right format and here is the code. After defining the schema, at the end, you can add a virtual function like so.

 ExamMetaSchema.virtual('fullname').get(function () {
   return `${this.firstname} ${this.lastname}`;