1
我有两种模式:NewsItem和user。每个NewsItem属于一个用户。Loopback:如何在查询中包含关系结果
"relations": {
"user": {
"type": "belongsTo",
"model": "user",
"foreignKey": "publisherId"
}
}
该关系已保存在数据库中,以便正常工作。
我很难列出所有NewsItem与关联用户的名称。
app.models.NewsItem.find({
include: [
{
relation: 'user',
scope: {
fields: ['name']
}
}
]
}, function(err, newsItems) { ...
根据该文档(https://docs.strongloop.com/display/public/LB/Include+filter)的NewsItem.user将指向的关系方法,而不是用户实例。
有谁知道我如何访问用户名值?