How to create loopback 4 model, repository and controller without specifying an ID

橙三吉。 提交于 2020-01-25 06:49:23

问题


My model has a Composite Primary Key, composed by 3 columns. When I try to create everything using commands:

lb4 model
lb4 repository
lb4 controller

I can't find the way to specify those three camps combined are the PK, or to simply don't specify the id at all.

The firt step i'm forced to write an id is on the repository generator

When reaching lb4 controller step it force me to specify an id again

I'm new using this framework, and tried to search more info about this but unsuccessfully


回答1:


Loopback4 doesn't support composite keys out of the box currently. You can read more here as well: https://github.com/strongloop/loopback-next/issues/1830 A work around would be to declare a primary key when you run lb4 model and then, in your find, use the where clause to specify another key as well. This, of course, doesnt enforce uniqueness, but again, there currently is no composite key support.



来源:https://stackoverflow.com/questions/58590499/how-to-create-loopback-4-model-repository-and-controller-without-specifying-an

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