1

I have a user model with a property addresses:

@property.array(Address)
addresses: Array<Address>;

But I get an error:

Cannot start the application. Error: "items" property must be present if "type" is an array

According to Loopback documentation, I do not need to do anything else.

Any idea what is missing?

Community
  • 1
  • 1
Eduardo
  • 1,781
  • 3
  • 26
  • 61

2 Answers2

4

We usually don't declare arrays with Array type. The below code works for us. Try it out.

@property.array(Address)
addresses?: Address[];
Samarpan
  • 913
  • 5
  • 12
2

Loopback 4 (lb4)-

I had a requirement of creating a model property which would be an array of array. I tried to generate this property using lb4 CLI but I was not prompted for an array item type so I chose any.

The generated code was something like this-

@property({
  type: 'array',
  itemType: 'any'
})
extraInfo?: any[];
Varun Kumar
  • 2,543
  • 1
  • 23
  • 22