Can i have multi module with loopback models?

2019-09-19 22:11发布

I am new to loopback framework. My application will have too many models. I want put it different folders.For Example i want have this structure :

./server/models/frontend/user/user.js
./server/models/frontend/user/userType.js
./server/models/backend/permission.js

Can deploy this structure? If i use this structure can i use loopback CLI? Do you have any better way to categorize my models?

1条回答
ら.Afraid
2楼-- · 2019-09-19 22:59

This structure can be deployed and you can use the loopback CLI.

Loopback allows you to customize the configuration for the models. You can specify where the application should load your models by specifying the directories in the sources property of the model-config.json file. A simple example would be this:

server/model-config.json

"_meta": {
    "sources": [
      "loopback/common/models",
      "loopback/server/models",
      "../server/models/frontend/user",
      "../server/models/backend"
    ]
  },

You can view the sample configuration here: Loopback example model configuration

查看更多
登录 后发表回答