You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

23 lines
507 B

import "reflect-metadata"
import { Field, ObjectType } from "type-graphql"
import { BaseEntity, BeforeInsert, Column, Entity, PrimaryGeneratedColumn } from "typeorm"
import { hashPassword } from "./auth"
@ObjectType()
@Entity()
export class User extends BaseEntity {
@PrimaryGeneratedColumn()
id!: number
@Field()
@Column()
email: string = ""
@Column()
password: string = ""
@BeforeInsert()
async hashPassword() {
this.password = await hashPassword(this.password)
}
}