You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
belongTo isn't enough for "include" queries from other table #10974
Is it intended that sole "belongsTo" isn't enough to run queries on both sides
User.hasOne(Device)
Device.belongsTo(User)
i want to User.find({include:[Device]}) and Device.find({include: [User]})
but i need both relations (one per model) for that. I expected (according to docs) that single
hasOne or belongsTo is enough to run both queries, User.find and Device.find To Reproduce
Steps to reproduce the behavior:
Define models User, Device
set belongsTo association: Device.belongsTo(User)
run query from User side: User.find({include:[Device]})
See error that User is not associated to Device
What do you expect to happen?
Users with their devices
What is actually happening?
User is not associated to Device
Environment
Dialect:
mysql
postgres
[ x] sqlite
mssql
any
Sequelize version: 5.7.3
Node Version: 10.x
OS: window10
Hello :) Which part of the docs made you think that only one relation is enough? Sequelize can't infer the hasOne from the belongsTo because it could also be a hasMany for example.
Activity
papb commentedon May 20, 2019
Hello :) Which part of the docs made you think that only one relation is enough? Sequelize can't infer the
hasOnefrom thebelongsTobecause it could also be ahasManyfor example.demosglok commentedon May 20, 2019
hi, nice to have question answered so quickly:)
actually as for docs, smth from this chapter
http://docs.sequelizejs.com/manual/associations.html#difference-between-hasone-and-belongsto
especially "or" between "hasOne" and "belongsTo"
papb commentedon Jul 18, 2019
I will try to clarify the docs.