0

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 first step I am forced to write an id is on the repository generator

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

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

micstr
  • 5,080
  • 8
  • 48
  • 76

1 Answers1

2

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.

Vikram Khemlani
  • 555
  • 6
  • 17
  • If you want to use no ID, you have to not specify any default CRUD functions when running the commands, as default CRUD functions require an id – Vikram Khemlani Oct 28 '19 at 16:10