Loopback 4: How to edit metadata set by `@property` decorator on `Entity` props?

Viewed 147

I use a third party Entity class with custom props. I extend it and need to add additional meta to already existing props defined inside the class I extend.

Here a code example. It doesn't work and is written only to explain better what I would like to accomplish:

export abstract class MyEntity extends ThirdPartyEntity {
  @property({
    // This is additional meta I want to add.
    myMetaProp: 'some value'
  })
  // This prop is already defined and decorated with `@property` in the `ThirdPartyEntity`.
  thirdPartyProp: string;
}

As mentioned above, this doesn't work. It produces this error - @property cannot be applied more than once on. You can't add/remove or override alltogether the meta defined by the @property decorator.

I resolved to use this workaround MyEntity.definition.properties.thirdPartyProp.myMetaProp = 'some value'.

The question is: is there any better and declarative way of editing the props meta? I've tried with MetadataInspector.defineMetadata but accomplished nothing.

0 Answers
Related