jwt-refresh-token-node-js icon indicating copy to clipboard operation
jwt-refresh-token-node-js copied to clipboard

where to find setRoles()?

Open willow7777 opened this issue 3 years ago • 1 comments

I've been trying to study the code but can't find the setRoles() function, as follows:

can you tell me where to find it? User.create({ // INSERT username: req.body.username, email: req.body.email, password: bcrypt.hashSync(req.body.password, 8) }) .then(user => { if (req.body.roles) { Role.findAll({ where: { name: { [Op.or]: req.body.roles } } }).then(roles => { user.setRoles(roles).then(() => { res.send({ message: "User registered successfully!" }); }); }); } else { // user role = 1 user.setRoles([1]).then(() => { res.send({ message: "User registered successfully!" }); }); } }) .catch(err => { res.status(500).send({ message: err.message }); });

willow7777 avatar Nov 05 '21 05:11 willow7777

SetRoles is the builtin function provided by sequelize nodejs library https://sequelize.org/ it is defined by the relation between the tables.

bparesh avatar May 02 '23 15:05 bparesh