问题
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:
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
来源:https://stackoverflow.com/questions/35874951/can-i-have-multi-module-with-loopback-models