Document instance methods can also be defined using the methods, schema property. For instance:
UserSchema.methods.setFullName = function setFullName(v) { const fullName = String(v).split(' ') this.lastName = fullName[0] || '' this.firstName = fullName[1] || '' }