Skip to content

Commit

Permalink
removed gender
Browse files Browse the repository at this point in the history
  • Loading branch information
wanying1804 committed Aug 17, 2021
1 parent 9dfd9d3 commit b535b04
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 23 deletions.
4 changes: 0 additions & 4 deletions src/auth/dto/register.input.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { InputType, Field } from '@nestjs/graphql';
import { UserGender } from '../../users/entities/user.entity';

@InputType()
export class RegisterInput {
Expand All @@ -11,7 +10,4 @@ export class RegisterInput {

@Field()
readonly password: string;

@Field()
readonly gender: UserGender;
}
4 changes: 0 additions & 4 deletions src/migration/1628761611815-AddUserRole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ export class AddUserRole1628761611815 implements MigrationInterface {
await queryRunner.query(
`ALTER TABLE users ADD role VARCHAR(255) DEFAULT 'player' AFTER email`,
);
await queryRunner.query(
`ALTER TABLE users ADD gender VARCHAR(255) NULL AFTER role`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE users DROP COLUMN role`);
await queryRunner.query(`ALTER TABLE users DROP COLUMN gender`);
}
}
13 changes: 0 additions & 13 deletions src/users/entities/user.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ export enum UserRole {
PLAYER = 'player',
}

export enum UserGender {
MALE = 'male',
FEMALE = 'female',
}

@ObjectType()
@Entity({ name: 'users' })
export class User {
Expand All @@ -43,14 +38,6 @@ export class User {
})
role!: UserRole;

@Field({ nullable: true })
@Column({
type: 'enum',
enum: UserGender,
nullable: true,
})
gender!: UserGender;

@Field()
@Column({
type: 'varchar',
Expand Down
3 changes: 1 addition & 2 deletions src/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class UsersService {
}

async create(registerInput: RegisterInput): Promise<User> {
const { name, email, password, gender } = registerInput;
const { name, email, password } = registerInput;

// check if the user exists in the db
const userInDb = await this.userRepo.findOne({
Expand All @@ -57,7 +57,6 @@ export class UsersService {
const user: User = await this.userRepo.create({
name,
email,
gender,
password,
});
await this.userRepo.save(user);
Expand Down

0 comments on commit b535b04

Please sign in to comment.