What I'm trying to do is something like that :
Schema
.virtual('getSomething')
.get(function(what) {
if (!what) {
return this.somethingElse
} else {
return this.something[what]
}
})
The problem is that we can't pass arguments in a virtual getter, how can I achieve something like that without having to duplicate my code ?
Add it as an instance method instead of a virtual getter.
Getters don't accept any arguments, because they are supposed to replace normal "get attribute" functionality, without brackets. So what you are need is to define a method:
and then you can simply call: