feat: add medical test entities

This commit is contained in:
2026-05-23 11:02:20 +03:30
parent 7186af8e7f
commit 7dda2564a8
32 changed files with 389 additions and 11 deletions
+44
View File
@@ -0,0 +1,44 @@
import {
BeforeInsert,
Column,
CreateDateColumn,
Entity,
Index,
PrimaryGeneratedColumn,
} from 'typeorm';
@Entity()
@Index(['phone', 'used'])
export class OTP {
@PrimaryGeneratedColumn()
id: number;
@Index()
@Column({
type: 'varchar',
length: 11,
nullable: false,
})
phone: string;
@Column({
type: 'varchar',
nullable: false,
})
code: string;
@CreateDateColumn()
createdAt: Date;
@Index()
@Column({ type: 'timestamptz' })
expiresAt: Date;
@Column({ type: 'boolean', default: false })
used: boolean;
@BeforeInsert()
setExpiry() {
this.expiresAt = new Date(Date.now() + 2 * 60 * 1000);
}
}