I have a users table that I have associated with an assets table by the user ID. I created the hasMany association from the users table to the assets table and the belongsTo association from the assets table to the users table. When I perform a findAll on the assets table I get the proper user information back based on the associations made. The problem is that the user record has the password hash and other properties coming with it that I done want. I only want the name coming with this association.
I have tried using the attributes tag inside the association but that didn't work.
Model.associate = (models) => { Model.belongsTo(models.User, { as: 'user' }); } Model.associate = (models) => { Model.hasMany(models.Asset); } If I can exclude columns, I would only expect to see the user's first name and last name come back from the users table.
attributesis used on the query, inside the association. Check this for an example.