Having 4 schemas in this example, namely Picture
, Video
, and Game
, where each can have multiple Download
instances. While this setup works well when searching downloads from the invoker side (Picture
, Video
, and Game
), it becomes messy with multiple tables. The real challenge arises when trying to determine the invoker from the Download
side, as I need to look up 3 many-to-many tables before fetching the data.
I'm wondering if there is a feature in typeorm that could simplify this process or if my approach of designing many-to-many relationships with multiple schemas is fundamentally flawed. Have any of you encountered a similar issue? If yes, how did you go about solving it?
Thank you in advance
@Entity()
export class Picture {
@PrimaryGeneratedColumn()
id: number
@Column()
name: string
@ManyToMany(() => Download)
@JoinTable()
downloads: Download[]
}
@Entity()
export class Video {
@PrimaryGeneratedColumn()
id: number
@Column()
name: string
@ManyToMany(() => Download)
@JoinTable()
downloads: Download[]
}
@Entity()
export class Game {
@PrimaryGeneratedColumn()
id: number
@Column()
name: string
@ManyToMany(() => Download)
@JoinTable()
downloads: Download[]
}
@Entity()
export class Download {
@PrimaryGeneratedColumn()
id: number
@Column()
source: string
@Column()
status: string
@Column()
path: string
}