Initial
This commit is contained in:
59
listify-api/src/auth/user.entity.ts
Normal file
59
listify-api/src/auth/user.entity.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
OneToMany,
|
||||
PrimaryColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
import { ListTemplateEntity } from '../list-templates/list-template.entity';
|
||||
import { UserListEntity } from '../lists/user-list.entity';
|
||||
import { RefreshTokenEntity } from './refresh-token.entity';
|
||||
|
||||
@Entity('users')
|
||||
export class UserEntity {
|
||||
@PrimaryColumn({ type: 'varchar', length: 36 })
|
||||
id!: string;
|
||||
|
||||
@Index({ unique: true })
|
||||
@Column({ type: 'varchar', length: 320 })
|
||||
email!: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 160, nullable: true })
|
||||
name?: string | null;
|
||||
|
||||
@Column({ type: 'varchar', length: 255 })
|
||||
passwordHash!: string;
|
||||
|
||||
@Index({ unique: true })
|
||||
@Column({ type: 'varchar', length: 128, nullable: true })
|
||||
verificationToken?: string | null;
|
||||
|
||||
@Column({ type: 'boolean', default: false })
|
||||
verified!: boolean;
|
||||
|
||||
@CreateDateColumn({
|
||||
type: 'datetime',
|
||||
precision: 3,
|
||||
default: () => 'CURRENT_TIMESTAMP(3)',
|
||||
})
|
||||
createdAt!: Date;
|
||||
|
||||
@UpdateDateColumn({
|
||||
type: 'datetime',
|
||||
precision: 3,
|
||||
default: () => 'CURRENT_TIMESTAMP(3)',
|
||||
onUpdate: 'CURRENT_TIMESTAMP(3)',
|
||||
})
|
||||
updatedAt!: Date;
|
||||
|
||||
@OneToMany(() => RefreshTokenEntity, (refreshToken) => refreshToken.user)
|
||||
refreshTokens?: RefreshTokenEntity[];
|
||||
|
||||
@OneToMany(() => ListTemplateEntity, (template) => template.owner)
|
||||
templates?: ListTemplateEntity[];
|
||||
|
||||
@OneToMany(() => UserListEntity, (list) => list.owner)
|
||||
lists?: UserListEntity[];
|
||||
}
|
||||
Reference in New Issue
Block a user