如何爲Sails中的對象定義函數/實例方法?如何使用sails.js定義模型的實例方法
在水線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
}
},
}
但是當我嘗試做定義一個實例方法在帆模型屬性,該功能不會被添加到該對象。 我做錯了什麼?
環境: 帆(v0.8.94),節點(v0.8.16)
有與此對應的帆回購在GitHub上的問題:https://github.com/balderdashy/sails/issues/578 – Adrien