import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { ContractPartyEntity } from './contract-party.entity';

@Entity('contracts2')
export class ContractEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({ type: 'varchar', length: 128 }) name: string;
    @Column({ type: 'longtext' }) html: string;
    @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) created: Date;
    @Column({ type: 'datetime', nullable: true }) validated: Date;
    @Column({ type: 'datetime', nullable: true }) invalidated: Date;

    @OneToMany(() => ContractPartyEntity, (cpe) => cpe.contract)
    parties: ContractPartyEntity[];
}
