#nestjs #typeorm
Вопрос:
uaerEntity.tsx
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column()
username: string;
@Column({ unique: true })
email: string;
@Column()
password: string;
@CreateDateColumn()
create_date: Date;
@ManyToOne(() => Nation, (nation) => nation.id, { eager: true })
nation: number;
@ManyToOne(() => Role, (role) => role.id, { eager: true })
role: number;
}
UserController.tsx
findAll(): Promise<User[]> {
return this.usersRepository.find({
select: ['id', 'username', 'email', 'create_date', 'nation', 'role']
});
}
Результат:
[
{
"id": 70,
"username": "test",
"email": "aa@test.com",
"create_date": "2021-10-04T09:51:14.457Z",
"nation": {
"id": 2,
"nation": "Bermuda"
},
"role": {
"id": 3,
"role": "user"
}
}
]
Как я могу сделать так, чтобы результат стал ниже формата?
[{ «идентификатор»: 70, «имя пользователя»: «тест», «электронная почта»: «aa@test.com», «дата создания»: «2021-10-04T09:51:14.457 Z», «нация»: Бермудские острова, «роль»: «пользователь» }]
Большое спасибо!!!!!