tethys.backend/app/Models/utils.ts
Arno Kaimbacher 080c21126b - add validator for checking languages of translated titles and description
- add notification messages via notiwind.ts
- add Project.ts
- add new component TabelPersons.vue
- add additional routes
- npm updates
2023-03-24 11:41:52 +01:00

20 lines
700 B
TypeScript

import Database, {
// DatabaseQueryBuilderContract,
QueryClientContract,
TransactionClientContract,
} from '@ioc:Adonis/Lucid/Database';
import Config from '@ioc:Adonis/Core/Config';
export function getUserRoles(userId: number, trx?: TransactionClientContract): Promise<Array<string>> {
const { userRole } = Config.get('acl.joinTables');
return ((trx || Database) as QueryClientContract | TransactionClientContract)
.query()
.from('roles')
.distinct('roles.slug')
.leftJoin(userRole, `${userRole}.role_id`, 'roles.id')
.where(`${userRole}.user_id`, userId)
.then((res) => {
return res.map((r) => r.slug);
});
}