问题
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