Returning user_name in get admins

This commit is contained in:
2023-12-27 16:02:20 +03:00
parent 206baad511
commit cc8d747a7e

View File

@@ -11,8 +11,12 @@ export class AdminService {
async getAdmins() { async getAdmins() {
try { try {
this.logger.debug(`[admin.getAdmins]`); this.logger.debug(`[admin.getAdmins]`);
const admins = await this.adminRepository.find(); const admins = await this.adminRepository.find({ relations: { user: true }, select: { user_id: true, user: { user_name: true } } });
return admins; const result: { user_id: string; user_name: string }[] = admins.map((admin) => ({
user_id: admin.user_id,
user_name: admin.user.user_name,
}));
return result;
} catch (error) { } catch (error) {
this.logger.log(`[getAdmin] ${JSON.stringify({ error })}`); this.logger.log(`[getAdmin] ${JSON.stringify({ error })}`);
return []; return [];