import { Field, ID, ObjectType } from 'type-graphql';
import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
@Entity({ name: 'users' })
@ObjectType()
export class User {
@PrimaryGeneratedColumn('uuid') @Field(type => ID) id: string;
@Column() @Index({ unique: true }) @Field() email: string;
@Column() passwordHash: string;
@Column({ nullable: true }) @Field({ nullable: true }) firstName?: string;
@Column({ nullable: true }) @Field({ nullable: true }) lastName?: string;
@Field() get name () {
return `${this.firstName} ${this.lastName}`;
}
}