I am trying to set the "unique:true" attribute for the name property in my NestJS - MongoDB schema, but it is not working as expected by default.
@Schema()
export class User {
@Prop()
userId:string;
@Prop({
type:String,
required:true,
})
name:string;
@Prop({ required: true})
password:string;
@Prop({ required: true })
email:string;
@Prop({default:"user"})
role:string
}
This setup works fine for 'required' and 'default', however, the 'unique' field does not seem to be functioning properly.