tethys.backend/app/Models/utils.ts

19 lines
844 B
TypeScript

// import db from '@adonisjs/lucid/services/db';
// // import Config from '@ioc:Adonis/Core/Config';
// import config from '@adonisjs/core/services/config';
// import { QueryClientContract } from "@adonisjs/lucid/types/database";
// import { TransactionClientContract } from "@adonisjs/lucid/types/database";
// export function getUserRoles(userId: number, trx?: TransactionClientContract): Promise<Array<string>> {
// const { userRole } = config.get('acl.joinTables');
// return ((trx || db) 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);
// });
// }