小编Вла*_*лов的帖子

TypeORM选择实体,除了一些,其中id不等于条件

我有两个实体:

    @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

typescript typeorm

17
推荐指数
2
解决办法
6万
查看次数

标签 统计

typeorm ×1

typescript ×1