PostgreSQL类型Orm过滤器manyToMany关系

问题描述

我有2个具有ManyToMany关系的实体:

//branch entity
 @ManyToMany(
        (type) => User,(e) => e.branches
    )
    users: User[];


//user entity
   @ManyToMany(
        (type) => Branch,(e) => e.users,{   eager: true,cascade: false }
    )
    
    @JoinTable()
    branches: Branch[];


    @IsEnum(Role)
    @Column('text',{ default: Role.Client })
    role: Role;

如果用户列表中不包含角色为“客户端”的用户,我想查找分支。

如果我有,我需要这个

[
 Branch {
    id: '98007770-c924-43cd-988c-774492e1e759',name: 'poslovnica1',users: [ {role:'client'},{role:'superAdmin'} ]
  },Branch {
    id: '787007770-c924-43cd-988c-774492e1e759',name: 'poslovnica13',Branch {
    id: '36f5b1ad-6553-4b2f-936b-33fb4ca8e73e',name: 'poslovnica2',users: [ {role:'superAdmin' }]
  }
]

在我想要获取的过滤器之后,如果所有分支都没有用户 角色“客户”。 'superAdmin'或:

[
   Branch {
    id: '36f5b1ad-6553-4b2f-936b-33fb4ca8e73e',users: [ {role:'superAdmin'} ]
  }
]

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)