Optionalopt: Partial<ControllerOptions>Optional configuration.
The property decorator function.
In the following example, the @MapTo decorator passes each element of the
array passed as an argument to the child 'Relation' (SubProtocol)
constructor.
The SubProtocol then uses this value to set the length of array of number
in the data property.
class SubProtocol {
_size: number
@Count('_size')
@Uint8
data: number[]
constructor(size: number) {
this._size = size
}
}
class Protocol {
@MapTo([1, 2])
@Relation(SubProtocol)
field: SubProtocol[]
}
@MapTodecorator map each value of an array to a child relation constructor. This is useful when a property is an array, and you want each item in the array to be processed by a specific relation.