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 }}
This repository was archived by the owner on Nov 11, 2025. It is now read-only.
I need to restrict the visibility of some attributes to some roles, only when sending data to client, but I still need to access this properties from the instance using the readable "instance.attrib" syntax. So reading the documentation I see that with set() if you don't specify any role, by default it apply "self".
varuser=sequelize.define('user',{
...
rank: {type: Sequelize.STRING,roles: {self: {set: false,get: true}admin: true}}}user.set({rank: 'UBER'},{role: 'self'||undefined});// Will be ignored
So I thought the same apply for get(), and with this role definition:
password: {roles: {self: true,client: false}}
I could achieve what I want
//getter with no roles defined defaults to 'self'user.password//123//when returning to client:user.get({role: 'client'})//password is hidden
In short, I want to be able to only hide attributes when I need it
I need to restrict the visibility of some attributes to some roles, only when sending data to client, but I still need to access this properties from the instance using the readable "instance.attrib" syntax. So reading the documentation I see that with set() if you don't specify any role, by default it apply "self".
So I thought the same apply for get(), and with this role definition:
I could achieve what I want
In short, I want to be able to only hide attributes when I need it