-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Scopes attributes are not merged #4856
Copy link
Copy link
Closed
Labels
type: bugDEPRECATED: replace with the "bug" issue typeDEPRECATED: replace with the "bug" issue type
Description
Version : 3.13.0
Dialect : mysql
Given
var User = sequelize.define('User', {
username: {
type: DataTypes.STRING,
allowNull: false
},
about: {
type: DataTypes.STRING
},
password: {
type: DataTypes.STRING,
allowNull: false,
set: function (val) {
// Some encrypting logic
}
}
}, {
scopes: {
'public': {
attributes: [
'id',
'username',
'about'
]
},
'private': {
attributes: [
'password'
]
}
}
});When querying an instance with multiple scopes, scopes attributes do not get merged.
e.g.
User.scope('public','private').findOneById(1).then(function(user){
console.log(user.about); // Exists, attribute included from public scope
console.log(user.password); // Undefined, public and private attributes were not merged
});Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type: bugDEPRECATED: replace with the "bug" issue typeDEPRECATED: replace with the "bug" issue type