问题描述
我是回送框架的新手.我的应用程序将有太多模型.我想把它放在不同的文件夹中.例如,我想要这样的结构:
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
可以部署此结构吗?如果使用此结构,可以使用环回CLI吗?您有更好的方法对我的模型进行分类吗?
Can deploy this structure?If i use this structure can i use loopback CLI?Do you have any better way to categorize my models?
推荐答案
可以部署此结构,并且可以使用回送CLI.
This structure can be deployed and you can use the loopback CLI.
Loopback允许您自定义模型的配置.您可以通过在model-config.json
文件的sources
属性中指定目录来指定应用程序应在何处加载模型.一个简单的例子是这样:
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
这篇关于我可以使用带有环回模型的多模块吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!