【问题标题】:Is possible use an external 'model-config.json' file at Strongloop可以在 Strongloop 使用外部“model-config.json”文件
【发布时间】:2016-02-19 00:37:03
【问题描述】:

实际上,Strongloop 允许开发人员使用model-config.json 的默认文件。里面有很多模型定义。

我为什么要使用外部model-config.json

因为,我有几个项目共享相同的模型。目前我可以通过这种方式将模型指向父文件夹:

'model-config.json'

{
  "_meta": {
    "sources": [
      "loopback/common/models",
      "loopback/server/models",
      "../../shared-models-project/common/models", // this is external to the project
      "../common/models",
      "./models"
    ], ... 
}

但在进行此更改后,我注意到model-config.json 文件中也引用了所有模型。那么解决方案可能是使用位于shared-models-project/server/model-config.json 的外部model-config.json 而不是./server/model-config.json

但是……这可能吗?还有其他选择吗?

【问题讨论】:

    标签: models loopbackjs strongloop


    【解决方案1】:

    Loopback 还将查找 model-config.js (link),因此您可以使用以下内容创建该文件:

    module.exports = require('../../shared-models-project/server/model-config.json')

    这是你的意思吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-15
      • 2019-07-19
      • 1970-01-01
      • 1970-01-01
      • 2022-01-17
      • 1970-01-01
      • 2020-07-12
      • 2010-12-28
      相关资源
      最近更新 更多