简体   繁体   中英

Loopback: Change the models folder structure

I need change the models folder structure. According to the docs I can modify the json config file that by default is:

{
  "_meta": {
    "sources": [
      "loopback/common/models/**/*",
      "loopback/server/models/**/*",
      "../common/models",
      "./models"
    ],
    "mixins": [
      "loopback/common/mixins",
      "loopback/server/mixins",
      "../common/mixins",
      "./mixins"
    ]
  },

  ...
}

I've been trying to change to:

{
  "_meta": {
    "sources": [
      "loopback/common/models/**/",
      "loopback/server/models/**/*",
      "../common/models",
      "./models"
    ],
    "mixins": [
      "loopback/common/mixins",
      "loopback/server/mixins",
      "../common/mixins",
      "./mixins"
    ]
  },

  ...
}

But when I load the project, i get this error

Error: Model not found:

How to change the models default directory for models??

Just append your folder name.

{ 
  "_meta": {
    "sources": [
      "loopback/common/models/foldername",
      "loopback/server/models/foldername",
      "../common/models",
      "./models"
    ],
    "mixins": [
      "loopback/common/mixins",
      "loopback/server/mixins",
      "../common/mixins",
      "./mixins"
    ]
  },
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM