How can i build it that when a user exists with the username which i provide? That i redirect like username already exists? ```ts
import { HydratedDocument } from 'mongoose';
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
export type UserDocument = HydratedDocument<User>;
@Schema({
timestamps: true,
versionKey: false,
})
export class User {
@Prop({ required: true })
firstName: string;
@Prop({ required: true })
lastName: string;
@Prop({ required: true })
username: string;
@Prop({ required: true })
email: string;
@Prop({ required: true })
password: string;
@Prop()
createdAt!: Date;
@Prop()
updatedAt!: Date;
}
export const UserSchema = SchemaFactory.createForClass(User);
ts
import { IsEmail, IsNotEmpty, IsString } from 'class-validator';
export class CreateUserData {
@IsNotEmpty()
@IsString()
readonly firstName: string;
@IsNotEmpty()
@IsString()
readonly lastName: string;
@IsNotEmpty()
@IsString()
readonly username: string;
@IsNotEmpty()
@IsString()
@IsEmail()
readonly email: string;
@IsNotEmpty()
@IsString()
readonly password: string;
}