【问题标题】:MikroORM Eager is set to false yet the relation is still being loadedMikroORM Eager 设置为 false 但仍在加载关系
【发布时间】:2021-05-17 09:50:35
【问题描述】:

我有以下实体:

@Entity()
export class SomeEntity extends BaseEntity implements ISomeEntity {
@ManyToOne(() => OtherEntity, {
    nullable: true,
    eager: false
  })
  otherEntity: OtherEntity;
}

但在运行findOnefind 函数时,otherEntity 仍会被加载。

我不知道如何在不影响where 条件的情况下停止加载其他关系。因为这会导致循环问题。

基于这里的装饰器https://mikro-orm.io/docs/decorators/#manytoone

eager boolean yes 总是加载关系。

【问题讨论】:

    标签: node.js nestjs mikro-orm


    【解决方案1】:

    显然,在 MikroORM 中,它链接任何先前自动加载的关系,而不管渴望。这是设计使然。

    【讨论】:

    • 您能否提供此信息的文档链接?谢谢
    猜你喜欢
    • 2012-05-14
    • 1970-01-01
    • 1970-01-01
    • 2021-07-05
    • 1970-01-01
    • 2016-10-02
    • 2014-04-15
    • 1970-01-01
    • 2017-12-19
    相关资源
    最近更新 更多