Skip to content

Commit

Permalink
Add a route for getting only active roles
Browse files Browse the repository at this point in the history
  • Loading branch information
foodelevator committed Aug 22, 2023
1 parent a18a86b commit 5c59405
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 0 additions & 1 deletion models/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ module.exports = function(sequelize, DataTypes) {
}
});


return Group;
};
15 changes: 15 additions & 0 deletions routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ router.get('/roles', function (req, res) {
});
});

router.get('/active-roles', function (req, res) {
models.Role.findAll({
attributes: ['id', 'title', 'description', 'identifier', 'email', 'active'],
where: { "active": true },
include: [
{
model: models.Group,
attributes: ["name", "identifier"],
}
],
}).then(function (roles) {
res.json(roles);
});
});

router.get('/role/:identifier/', function (req, res) {
let identifier = req.params.identifier;
getOneRoleWithGroup({identifier}, res);
Expand Down

0 comments on commit 5c59405

Please sign in to comment.