Virtuals are properties that are added to the entities at runtime that are not persisted in the Datastore. You can both define a getter and a setter.
getter
constuserSchema=newSchema({ firstname: {}, lastname : {}});userSchema.virtual('fullname').get(functionfullName() {// the scope (this) is the entityData of the entity instance// for this reason don't use arrow functions herereturn`${this.firstname}${this.lastname}`;});constUser=gstore.model('User', schema);constuser=newUser({ firstname:'John', lastname:'Snow' });console.log(user.fullname); // 'John Snow';/* * You can also set virtuals to true when calling plain() on your entity * to add them to the object returned. */constresponse=user.plain({ virtuals:true });console.log(response.fullname); // 'John Snow';