Created
September 19, 2021 11:39
-
-
Save rskhan167/bcd062aecadf150fad93a386cd05bd07 to your computer and use it in GitHub Desktop.
Nestjs Series
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Property, Entity, Unique, PrimaryKey } from '@mikro-orm/core'; | |
import { IsEmail } from 'class-validator'; | |
@Entity() | |
export class User { | |
@PrimaryKey() | |
id!: number; | |
@Property() | |
name: string; | |
@Property() | |
@Unique() | |
@IsEmail() | |
email: string; | |
@Property() | |
password: string; | |
@Property({ nullable: true }) | |
profile_image?: string; | |
@Property() | |
createdAt = new Date(); | |
@Property({ onUpdate: () => new Date() }) | |
updatedAt = new Date(); | |
constructor( | |
name: string, | |
email: string, | |
password: string, | |
profile_image: string, | |
) { | |
this.name = name; | |
this.email = email; | |
this.password = password; | |
this.profile_image = profile_image; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment