234449f3c6
* Hide the person age if it is negative * Add validation to prevent future birth dates * Add comment * Add test, Add birth date validation and update birth date modal * Add birthDate validation in PersonService and SetBirthDateModal * Running npm run format:fix * Generating the migration file propoerly, and Make the birthdate form logic simpler * Make birthDate type only string * Adding useLocationPin back
53 lines
1.1 KiB
TypeScript
53 lines
1.1 KiB
TypeScript
import {
|
|
Check,
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
ManyToOne,
|
|
OneToMany,
|
|
PrimaryGeneratedColumn,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
import { AssetFaceEntity } from './asset-face.entity';
|
|
import { UserEntity } from './user.entity';
|
|
|
|
@Entity('person')
|
|
@Check(`"birthDate" <= CURRENT_DATE`)
|
|
export class PersonEntity {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string;
|
|
|
|
@CreateDateColumn({ type: 'timestamptz' })
|
|
createdAt!: Date;
|
|
|
|
@UpdateDateColumn({ type: 'timestamptz' })
|
|
updatedAt!: Date;
|
|
|
|
@Column()
|
|
ownerId!: string;
|
|
|
|
@ManyToOne(() => UserEntity, { onDelete: 'CASCADE', onUpdate: 'CASCADE', nullable: false })
|
|
owner!: UserEntity;
|
|
|
|
@Column({ default: '' })
|
|
name!: string;
|
|
|
|
@Column({ type: 'date', nullable: true })
|
|
birthDate!: Date | null;
|
|
|
|
@Column({ default: '' })
|
|
thumbnailPath!: string;
|
|
|
|
@Column({ nullable: true })
|
|
faceAssetId!: string | null;
|
|
|
|
@ManyToOne(() => AssetFaceEntity, { onDelete: 'SET NULL', nullable: true })
|
|
faceAsset!: AssetFaceEntity | null;
|
|
|
|
@OneToMany(() => AssetFaceEntity, (assetFace) => assetFace.person)
|
|
faces!: AssetFaceEntity[];
|
|
|
|
@Column({ default: false })
|
|
isHidden!: boolean;
|
|
}
|