I have 2 entities with the following many-to-one relation:
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[];
}
Now, i have a list of parent ids and i want to get all the children of all the parent id's, and i expected the following code to work:
const children: Child[] = await this.entityManager.find(Child, {
where: {
parent: In([1,2,3,4,5,6])
}
});
How can i do this without joining? and is it possible to do this without query builder?