Просмотр исходного кода

✨ feat(contracts): add client relationship to Hetong entity

- import ManyToOne decorator from typeorm
- add client field with @ManyToOne relationship to Client entity
- establish direct relationship between Hetong and Client entities for easier data access
yourname 8 месяцев назад
Родитель
Сommit
f5e0b94c3a
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      src/server/modules/contracts/hetong.entity.ts

+ 3 - 1
src/server/modules/contracts/hetong.entity.ts

@@ -1,4 +1,4 @@
-import { Entity, PrimaryGeneratedColumn, Column, Index, ForeignKey, OneToMany } from 'typeorm';
+import { Entity, PrimaryGeneratedColumn, Column, Index, ForeignKey, OneToMany, ManyToOne } from 'typeorm';
 import { HetongRenew } from './hetong-renew.entity';
 import { Client } from '../clients/client.entity';
 import { z } from '@hono/zod-openapi';
@@ -17,6 +17,8 @@ export class Hetong {
   @Column({ name: 'client_id', type: 'int', unsigned: true })
   @ForeignKey(() => Client)
   clientId!: number;
+  @ManyToOne(() => Client)
+  client!: Client;
 
   @Column({ name: 'project_id', type: 'varchar', length: 50, nullable: true })
   projectId?: string;