Page Contents

Home > @loopback/repository > hasMany

hasMany() function

Decorator for hasMany Calls property.array decorator underneath the hood and infers foreign key name from target model name unless explicitly specified


export declare function hasMany<T extends Entity>(targetResolver: EntityResolver<T>, definition?: Partial<HasManyDefinition>): (decoratedTarget: object, key: string) => void;


Parameter Type Description
targetResolver EntityResolver<T> Target model for hasMany relation
definition Partial<HasManyDefinition> (Optional) Optional metadata for setting up hasMany relation


(decoratedTarget: object, key: string) => void

A property decorator