sql - ObjectionJS:在两个子字段上的 HasMany 关系
问题描述
我目前正在使用 Objection 从 SQL 查询中获取不错的对象。
我有这样的比赛:
id integer primary key,
teamA integer references(teams.id),
teamB integer references(teams.id),
scoreA integer,
scoreB integer
我的 ObjectionTeam
类中有没有办法指定我的团队有matches
, 所以HasMany
关系,但可以在两个字段中找到。
如
static get relationMappings() {
return {
matches: {
relation: Model.HasManyRelation,
modelClass: Match,
join: {
from: ['matches.teamA', 'matches.teamB'],
to: 'teams.id',
}
}
};
}
提前致谢
解决方案
推荐阅读
- angular - 使用 ng-sidebar 作为组件的 Angular 侧边栏不起作用
- python - 使用 BeautifulSoup 遍历 div 表
- django - 根据所选位置在 DateTime 字段上设置时区 - Django ModelForm UpdateView
- react-native - 构建自定义输入组件
- java - 谁能告诉我如何在java中同时删除两个元素?
- reactjs - 居中的图标和文本(React Material-UI)
- javascript - 使用 filter() 和 includes() 过滤数组
- python - 如何拆分列表内的数据并附加到新列表
- c# - 无法统一使用UI按钮切换到特定场景,为什么?
- redis - 即使等待,solaris 10 中的僵尸进程