Page Contents

Home > @loopback/repository > HasOneRepository > get

HasOneRepository.get() method

Find the only target model instance that belongs to the declaring model.


get(filter?: Pick<Filter<Target>, Exclude<keyof Filter<Target>, 'where'>>, options?: Options & {
        polymorphicType?: string | string[];
    }): Promise<Target>;


Parameter Type Description
filter Pick<Filter<Target>, Exclude<keyof Filter<Target>, ‘where’>> (Optional) Query filter without a Where condition
options Options & { polymorphicType?: string | string[]; } (Optional) Options for the operations options.polymorphicType - a string or a string array of polymorphic type names to specify which repositories should are expected to be searched It is highly recommended to contain this param especially for datasources using deplicated ids across tables



A promise resolved with the target object or rejected with an EntityNotFoundError when target model instance was not found.