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 a model with no defaultScope defined explicitly. So when I do:
Token.scope('defaultScope').findAll()
I get an error:
Error: Invalid scope defaultScope called.
at W:\dev\node_modules\sequelize\lib\model.js:1214:13
When I try to add a defaultScope using Token.addScope('defaultScope', {}) (without setting the override: true flag) I get another error:
Error: The scope defaultScope already exists. Pass { override: true } as options to silence this error
at [object Object].Model.addScope (W:\temp\node_modules\sequelize\lib\model.js:1100:11)
So it looks like a defaultScope is not defined thus invalid but at the same time it seems to be defined internally because I get an error that it is already defined (which it is not really).
In my usecase I want to execute database operations based on REST requests. So: GET /users/2
is mapped to: Users.scope(req.query.scope || 'defaultScope').findById(req.params.id);
Since defaultScope is not explicitly defined, I get the error above. I think it would be nice (and probably wouldn't cause any problems) if an "empty" defaultScope is always defined (defaulting to {}). Or option 2: allow to set a defaultScope using the addScope() method without being forced to set the override flag.
The text was updated successfully, but these errors were encountered:
I have a model with no
defaultScope
defined explicitly. So when I do:Token.scope('defaultScope').findAll()
I get an error:
When I try to add a defaultScope using
Token.addScope('defaultScope', {})
(without setting theoverride: true
flag) I get another error:So it looks like a
defaultScope
is not defined thus invalid but at the same time it seems to be defined internally because I get an error that it is already defined (which it is not really).In my usecase I want to execute database operations based on REST requests. So:
GET /users/2
is mapped to:
Users.scope(req.query.scope || 'defaultScope').findById(req.params.id);
Since
defaultScope
is not explicitly defined, I get the error above. I think it would be nice (and probably wouldn't cause any problems) if an "empty"defaultScope
is always defined (defaulting to{}
). Or option 2: allow to set adefaultScope
using theaddScope()
method without being forced to set theoverride
flag.The text was updated successfully, but these errors were encountered: