小编Adr*_*ien的帖子

如何使用sails.js为模型定义实例方法

如何在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)

model function node.js sails.js waterline

11
推荐指数
1
解决办法
6960
查看次数

标签 统计

function ×1

model ×1

node.js ×1

sails.js ×1

waterline ×1