【发布时间】:2021-05-05 09:58:03
【问题描述】:
考虑以下实体:
@Entity()
export class One {
@ManyToOne(() => Two, two => two.oneSomeString)
@PrimaryColumn()
public readonly someString!: string
@PrimaryColumn()
public readonly someNumber!: number
}
@Entity()
export class Two {
@PrimaryGeneratedColumn()
id!: number
@OneToMany(() => One, one => one.someString, { cascade: true })
@Column()
public readonly oneSomeString!: string
我希望Two 的每条记录仅通过someString 而不是整个PK 识别One 的多条记录(因此仅通过someString 进行级联删除)。
【问题讨论】:
标签: postgresql typeorm