In my scenario, I am dealing with two entities:
@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[];
}
My objective is to retrieve products where any object within the prohibitedToSaleOn
array of Point
's meets a certain condition
point.id != {idWhatIWant}
Ultimately, I aim to fetch all products that are not restricted from sales at a specific point. To achieve this, I have attempted the following query:
return this.productRepository.createQueryBuilder('product')
.leftJoin('product.prohibitedToSaleOn', 'point')
.where('point.id != :id', {id})
.getMany();
Unfortunately, this query is not producing the desired results. I am seeking assistance in constructing the correct query. Thank you =)
P.S. I am utilizing PostgreSQL