gpt4 book ai didi

javascript - Sequelize : 1:m mapping through junction table

转载 作者:行者123 更新时间:2023-12-03 22:42:28 25 4
gpt4 key购买 nike

有没有办法通过连接表反转 1:m 映射( Group hasMany Users )?

Group.hasMany(Users, { through: 'junctionTable'}) 
User.hasOne(Group, {through: '????'})

文档并没有真正说明 hasOne 是否支持 through

最佳答案

尝试之后,是的,实际上将 {through: 'junctionTable'} 传递给 hasOne 会起作用。

尽管必须将 hasMany 更改为 belongsToMany 以允许连接表。

关于javascript - Sequelize : 1:m mapping through junction table,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33564758/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com