如何在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
}
},
}
但是当我尝试在中定义实例方法时 属性 在Sails中的模型中,该函数未添加到对象中。 难道我做错了什么 ?
环境: 风帆(v0.8.94),节点(v0.8.16)