I have 2 tables, lists and items. A list can have 0 or many items. An item is only in one list.
export class List {
@OneToMany(() => Item, (item) => item.list, {
nullable: true,
})
items: Item[];
}
export class Item {
@ManyToOne(() => List, (list) => list.items)
list: List;
}
- How can I get all the
listobjects that have 0 item?
My code below is returning an error: Unknown column 'list.items' in 'where clause'.
const listsWithoutItems = await this.listsRepository
.createQueryBuilder('list')
.where('list.item IS NULL')
.getMany();