module.exports = Self => { Self.remoteMethod('activeWithInheritedRole', { 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: `/activeWithInheritedRole`, verb: 'GET' } }); Self.activeWithInheritedRole = 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.userFk JOIN account.roleRole i ON i.role = u.role JOIN account.role r ON r.id = i.inheritsFrom`; return Self.activeWorkers(query, filter); }; };