Skip to content
Snippets Groups Projects
user.schema.ts 533 B
Newer Older
  • Learn to ignore specific revisions
  • import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
    import { Document } from 'mongoose';
    
    import { UserRole } from './enum/user-role.enum';
    
    
    export type UserDocument = User & Document;
    
    @Schema()
    export class User {
    
      email: string;
    
    
      password: string;
    
      @Prop({ default: false })
      emailVerified: boolean;
    
    
      @Prop({ enum: [UserRole.admin, UserRole.user], default: UserRole.user })
      role: number;
    
    }
    
    export const UserSchema = SchemaFactory.createForClass(User);