import { Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from "typeorm"; import { Gallery, Product } from ".."; @Entity({ comment: "Asociación entre los productos y la galería de imágenes.", name: "product_image", }) export class ProductImage { @PrimaryGeneratedColumn({ type: "int", comment: "Id único de cada registro.", }) id: number; @ManyToOne(() => Product, (product) => product.products_image, { onDelete: "CASCADE", onUpdate: "NO ACTION", }) @JoinColumn({ name: "product" }) product: Product; @ManyToOne(() => Gallery, (gallery) => gallery.product_images, { onDelete: "CASCADE", onUpdate: "NO ACTION", }) @JoinColumn({ name: "image" }) image: Gallery; }