我的@ManyToMany
中有一个关系UserEntity
:
@ManyToMany(
() => Order,
orders=> orders.users,
)
orders?: Order[];
如何通过一个查询从该表中获取数据?
我试试这个:
const user = await this.conn
.getRepository(UserEntity)
.createQueryBuilder('user')
.addSelect('firstName')
.addSelect('lastName')
.leftJoin('user.order', 'order', 'order.id = user.id')
.getRawMany();
但是启动后,我的控制台会抛出我:
[Nest] 1262 - 07/20/2020, 12:47:41 PM [ExceptionsHandler] Column 'id' in field list is ambiguous +1670ms
QueryFailedError: Column 'id' in field list is ambiguous
感谢您的帮助