Page Contents

Home > @loopback/repository > belongsTo

belongsTo() function

Decorator for belongsTo


export declare function belongsTo<T extends Entity>(targetResolver: EntityResolver<T>, definition?: Partial<BelongsToDefinition>, propertyDefinition?: Partial<PropertyDefinition>): (decoratedTarget: Entity, decoratedKey: string) => void;


Parameter Type Description
targetResolver EntityResolver<T> A resolver function that returns the target model for a belongsTo relation
definition Partial<BelongsToDefinition> (Optional) Optional metadata for setting up a belongsTo relation
propertyDefinition Partial<PropertyDefinition> (Optional) Optional metadata for setting up the property


(decoratedTarget: Entity, decoratedKey: string) => void

A property decorator