loopbackjs - loopback 4 是否嵌入了一个并嵌入了许多可用的关系?
问题描述
我正在将我的 LoopBack 3 应用程序迁移到 LoopBack 4。在 lb3 应用程序中,我使用嵌入一个并在我的模型中嵌入了许多功能,但无法在 lb4 中找到相同的关系。通过文档。它尚未实施。文档是否已过时或不可用?有没有解决方法?
解决方案
当您尝试添加时,它无法在关系中看到。但在这个问题上,他们认为他们已经修复了它。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;
}
创建一个模型,然后在该模型类内部编写您的子模块。并将其作为属性添加到您的主模块中。然后就没事了。
推荐阅读
- python - 如何从python中的.xls文件中读取多个表?
- visual-studio - 使用 Outlook 插件将旧电子邮件(> 6 个月)从 Outlook 复制到外部位置
- jquery - 单击时避免下拉子菜单元素关闭主下拉菜单
- javascript - 邮件订阅——成功与错误信息切换
- javascript - DoubleClick for publishers:显示自适应广告
- oracle - PL/SQL编写的最长公共子序列算法优化
- kubernetes - HPA 无法从自定义指标 API 获取指标
- ruby-on-rails - VCR.request_matcher.uri_without_params 方法,但用于忽略动态主体值
- javascript - 从可重用组件传递 Route 作为道具
- uwp - Hololens 中不需要注视应用程序窗口的语音/语音识别