implement file module and add files relation to booking entity and populate on fetch

This commit is contained in:
marshal
2026-05-25 10:19:08 +03:00
parent ae317540c1
commit 9432814e3b
12 changed files with 245 additions and 44 deletions

View File

@@ -1,5 +1,6 @@
import { BaseEntity } from "@edr/api-common";
import { Column, Entity } from "typeorm";
import { Column, Entity, OneToMany } from "typeorm";
import { FileRecord } from "../../files/entities/file.entity";
@Entity({ schema:"freight",name: "bookings" })
export class Booking extends BaseEntity {
@@ -138,7 +139,10 @@ export class Booking extends BaseEntity {
@Column({ name: "consolidation_partner_id", type: "uuid", nullable: true })
consolidationPartnerId?: string | null;
// ── documents (JSONB) ──────────────────────────────────────────────────
@Column({ name: "documents", type: "jsonb", nullable: true })
documents?: Record<string, { originalName: string; size: number; mimeType: string; url?: string }> | null;
// ── files ────────────────────────────────────────────────────────────
@OneToMany(() => FileRecord, (file) => file.resourceId, {
createForeignKeyConstraints: false,
})
files?: FileRecord[];
}