我有2个具有以下多对一关系的实体:
Child.ts:
@Entity({name: "children"})
export class Child {
@PrimaryGeneratedColumn()
child_id: number;
@Column()
name: string;
@ManyToOne(type => Parent, parent => parent.children)
@JoinColumn({ name: "parent_id" })
parent: Parent;
}
Parent.ts
@Entity({name: "parents"})
export class Parent {
@PrimaryGeneratedColumn()
parent_id: number;
@Column()
name: string;
@OneToMany(type => Child, children=> children.parent)
children: Child[];
}
现在,我有一个父母ID的列表,我想获取所有父母ID的所有孩子,并且我希望以下代码可以工作:
const children: Child[] = await this.entityManager.find(Child, {
where: {
parent: In([1,2,3,4,5,6])
}
});
不加入我该怎么办?并且有可能在没有查询生成器的情况下做到这一点?