我有两个实体:
@Entity()
export class Point {
@PrimaryGeneratedColumn('uuid')
id: string;
// some other stuff
}
@Entity()
export class Product {
@PrimaryGeneratedColumn('uuid')
id: string;
@IsOptional()
@ManyToMany(() => Point)
@JoinTable()
prohibitedToSaleOn: Point[];
}
Run Code Online (Sandbox Code Playgroud)
我想要获得产品,其中prohibitedToSaleOn(数组Point)中的任何对象都满足条件
point.id != {idWhatIWant}
所以,最后我想获得所有产品,而不是在选定的点禁止销售。我做了这样的事情:
return this.productRepository.createQueryBuilder('product')
.leftJoin('product.prohibitedToSaleOn', 'point')
.where('point.id != :id', {id})
.getMany();
Run Code Online (Sandbox Code Playgroud)
但它不起作用(根本不应该)
我需要有关正确请求的帮助。谢谢=)
PS我使用PostgreSQL