首页 > 解决方案 > loopback 4 是否嵌入了一个并嵌入了许多可用的关系?

问题描述

我正在将我的 LoopBack 3 应用程序迁移到 LoopBack 4。在 lb3 应用程序中,我使用嵌入一个并在我的模型中嵌入了许多功能,但无法在 lb4 中找到相同的关系。通过文档。它尚未实施。文档是否已过时或不可用?有没有解决方法?

标签: loopbackjsloopback4

解决方案


当您尝试添加时,它无法在关系中看到。但在这个问题上,他们认为他们已经修复了它。https://github.com/strongloop/loopback-next/issues/2130

这是使用示例。

@model()
export ExampleMainClass extends Entity{
  @property({
    type: 'string',
    id: true,
    generated: true,
  })
  id: string;

  @property()
  key: ExampleSubClass;
}

@model()
class ExampleSubClass{
  @property({
    type: 'string',
    id: true,
    generated: true,
  })
  id: string;

  @property({
    type: 'string',
    required: true,
  })
  name: string;

}

创建一个模型,然后在该模型类内部编写您的子模块。并将其作为属性添加到您的主模块中。然后就没事了。


推荐阅读