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
I have two models in n:m association, A and B, and third one in association with A in 1:n association. Default scope of B has include: [() => C] but I want to specify in default scope of A not to include C when loading B, so I created a new scope on B which doesn't include C.
Sequelize docs says that you can say B.scope('scopeName') (the last example in this section). When I try to do that like include: [() => B.scope('scopeName')], I get next error on app start:
Invalid scope scopeName called.
at /node_modules/sequelize/lib/model.js:1224:13
at Array.forEach (native)....
I've noticed that it can be due to the fact that A comes before B, so when the lib tries to load model A it hasn't loaded model B yet so it's logical why is this scope invalid.
But when I change the order of model loading (A becomes B and B becomes A), I get another error:
TypeError: self.$expandAttributes is not a function
at conformOptions (/node_modules/sequelize/lib/model.js:250:10)
at conformInclude (/node_modules/sequelize/lib/model.js:307:5)
So my question is if this scoped include is supported in sequelize-typescript or not? And if it is, what's the syntax?
EDIT: I forgot to mention I'm using v3 of Sequelize.
The text was updated successfully, but these errors were encountered:
I have two models in n:m association,
A
andB
, and third one in association withA
in 1:n association. Default scope ofB
hasinclude: [() => C]
but I want to specify in default scope ofA
not to includeC
when loadingB
, so I created a new scope onB
which doesn't includeC
.Sequelize docs says that you can say
B.scope('scopeName')
(the last example in this section). When I try to do that likeinclude: [() => B.scope('scopeName')]
, I get next error on app start:I've noticed that it can be due to the fact that
A
comes beforeB
, so when the lib tries to load modelA
it hasn't loaded modelB
yet so it's logical why is this scope invalid.But when I change the order of model loading (
A
becomesB
andB
becomesA
), I get another error:So my question is if this scoped include is supported in
sequelize-typescript
or not? And if it is, what's the syntax?EDIT: I forgot to mention I'm using
v3
of Sequelize.The text was updated successfully, but these errors were encountered: