dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 379 forks source link

Add custom getters / setters using get / set #607

Open eclipse1985 opened 9 years ago

eclipse1985 commented 9 years ago

Hi,

I'm using node-orm for read and manipulating mysql entities behind an express layer that exposes a set of restful api. My problem is that I want to print the resulting json using the res.json() express method, and this method reads the properties but not call any method except the "standard" get / set way of defining getters/setters. Is it possible to write something like:

methods: {
                fullname: {
                    enumerable: true,
                    get: function() {
                        return this.firstname + this.lastname;
                    }
                }
}

instead of:

methods: {
                getFullname: function(){
                        return this.firstname + this.lastname;                    
                }
}

in Model definition?