【发布时间】:2014-05-16 03:57:03
【问题描述】:
我想知道,是否可以在sails 中使用自定义属性来查询某些记录? 也许我下面的例子会更好地解释它。
模型/User.js
attributes: { first_name: 'string', last_name: 'string' }
模型/ModelA.js
attributes: {
user: {model: 'User'},
studentName: function(){ return this.user.first_name + " " this.user.last_name },
....
}
我的查询
ModelA.find({studentName: {contains: searchKeyword }}).populate('user').then(console.log);
提前谢谢各位。
【问题讨论】:
标签: node.js sails.js waterline