32 lines
869 B
JavaScript
32 lines
869 B
JavaScript
|
|
module.exports = Self => {
|
|
Self.remoteMethod('activeWithRole', {
|
|
description: 'Returns active workers with a role',
|
|
accessType: 'READ',
|
|
accepts: [{
|
|
arg: 'filter',
|
|
type: 'Object',
|
|
description: 'Filter defining where and paginated data',
|
|
required: true
|
|
}],
|
|
returns: {
|
|
type: ['object'],
|
|
root: true
|
|
},
|
|
http: {
|
|
path: `/activeWithRole`,
|
|
verb: 'GET'
|
|
}
|
|
});
|
|
|
|
Self.activeWithRole = async filter => {
|
|
const query =
|
|
`SELECT DISTINCT w.id, w.firstName, w.lastName, u.name, u.nickname
|
|
FROM worker w
|
|
JOIN account.user u ON u.id = w.id
|
|
JOIN account.role r ON r.id = u.role`;
|
|
|
|
return Self.activeWorkers(query, filter);
|
|
};
|
|
};
|