I'm trying to create an instance method to check if a user hasRoles based on an array of role names (strings) passed to it
async checkHasRole(roles) {
return await this.hasRoles(roles);
}
however this runs this query
SELECT `Role`.`id` FROM `Roles` AS `Role` INNER JOIN `role_user` AS `Role_User` ON `Role`.`id` = `Role_User`.`RoleId` AND `Role_User`.`UserId` = 231 WHERE (((`Role`.`id` = 'staff')))
It's referencing the Role.id.
Please how can I change this to reference the Role.name and use an IN operator instead and completely scrap out the ID
I tried importing the Role Model in the User class model but running findAll returns undefined.
Please help, thanks