jwt-refresh-token-node-js
jwt-refresh-token-node-js copied to clipboard
where to find setRoles()?
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 }); });
SetRoles is the builtin function provided by sequelize nodejs library https://sequelize.org/ it is defined by the relation between the tables.