【发布时间】:2016-04-21 17:35:49
【问题描述】:
我有一个如下的 FollowMap
{
"name": "FollowMap",
.
.
.
"relations": {
"follower_acc": {
"type": "belongsTo",
"model": "Account",
"foreignKey": "follower_id"
},
"following_acc": {
"type": "belongsTo",
"model": "Account",
"foreignKey": "following_id"
}
}
}
我想与我的 Account 模型建立关系,这样我就可以获得一个用户关注者和关注列表,Account 模型如下;
{
"name": "Account",
.
.
.
"followers": {
"type": "hasMany",
"model": "FollowMap",
"foreignKey": "following_id"
},
"following": {
"type": "hasMany",
"model": "FollowMap",
"foreignKey": "follower_id"
}
}
}
从关系中,我可以获取帐户的关注者和关注计数,但是,我无法从这些关系中获取关注者和关注的帐户列表。我希望它很清楚。
【问题讨论】:
标签: node.js loopbackjs