如何在Sails中为对象定义函数/实例方法?
在Waterline doc(https://github.com/balderdashy/waterline)中,他们说:
var User = Waterline.Collection.extend({
...
attributes: {
...
// You can also define instance methods here
fullName: function() {
return this.firstName + ' ' + this.lastName
}
},
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试在Sails中的模型中的属性中定义实例方法时,该函数不会添加到对象中.难道我做错了什么 ?
环境:风帆(v0.8.94),节点(v0.8.16)