correction de l'erreur avec exclude

This commit is contained in:
batche
2022-10-28 18:41:26 +02:00
parent e401665e71
commit 6879ddaac8
15 changed files with 16 additions and 26 deletions

View File

@@ -5,12 +5,10 @@ import { UsersModule } from './users/users.module';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ConfigModule } from '@nestjs/config';
import { FriendshipsModule } from './friendship/friendships.module';
import { AuthenticationController } from './auth/authentication.controller';
@Module({
imports: [UsersModule,
FriendshipsModule,
// RouterModule.register(routesForUsers),
ConfigModule.forRoot(),
TypeOrmModule.forRoot({
type: 'postgres',

View File

@@ -1,5 +1,5 @@
import { Exclude } from 'class-transformer';
import { IsEmail, IsString } from 'class-validator';
import { Unique } from 'typeorm';
export class CreateUsersDto {
@IsString()
@@ -7,6 +7,5 @@ export class CreateUsersDto {
@IsEmail()
readonly email: string;
@IsString()
@Exclude()
readonly password: string;
}

View File

@@ -5,25 +5,20 @@ import { Friendship } from "../../friendship/entities/friendship.entity";
@Entity('user')
// @Unique(['email', 'username'])
@Unique(['email', 'username'])
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column()
@Length(5, 25)
username: string;
@Column()
@IsEmail()
email: string;
//Dans le cadre d'un tableau on peut faire :
// @Column('json', { nullable: true })
@Column()
// @Exclude()
password: string;
@Column('json', { nullable: true })
@@ -36,8 +31,4 @@ export class User {
@JoinTable()
@OneToMany(type => Friendship , (friendship) => friendship.addresseeId)
addresseeId: Friendship[];
// constructor(partial: Partial<User>) {
// Object.assign(this, partial);
// }
}

View File

@@ -26,8 +26,9 @@ export class UsersController {
}
@Post()
@HttpCode(HttpStatus.GONE)
@HttpCode(HttpStatus.CREATED)
create(@Body() createUsersDto : CreateUsersDto ) {
console.log(createUsersDto);
return this.usersService.create(createUsersDto);
}

View File

@@ -49,6 +49,7 @@ export class UsersService {
}
async update(id: string, updateUserDto: UpdateUsersDto) {
console.log(`Update user ${id} with ${updateUserDto}`);
const user = await this.userRepository.preload(
{id: +id,
...updateUserDto});