sequelize attributes exclude all code example
Example 1: sequelize exclude attribute
User
.findAll({
attributes: {exclude: ['password']},
order: [['id','DESC']]})
.then( users => {
return reply( ReplyUtil.ok(users) );
})
.catch( err => {
return reply( ReplyUtil.badImplementation(err) );
});
Example 2: sequelize attributes exclude all
attributes: []
Example 3: sequelize exclude attributes
const my_model = await MyModel.findById(id, {
include: [
{
model: AnotherModel,
attributes: [ 'displayName', 'email' ]
},
{ model: YetAnotherModel,
include: [{
model: AnotherModel,
attributes: [ 'id', 'displayName', 'email' ]
}]
}
]
})