Can i have multi module with loopback models?

守給你的承諾、 提交于 2019-12-13 07:10:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!