Reputation: 1831
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?
Upvotes: 1
Views: 2958
Reputation: 2751
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[];
Upvotes: 2
Reputation: 943
We usually don't declare arrays with Array type. The below code works for us. Try it out.
@property.array(Address)
addresses?: Address[];
Upvotes: 4