@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
40 lines (26 loc) • 1.75 kB
Markdown
---
lang: en
title: 'API docs: repository.hasonerepository.get'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/repository
permalink: /doc/en/lb4/apidocs.repository.hasonerepository.get.html
---
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/repository](./repository.md) > [HasOneRepository](./repository.hasonerepository.md) > [get](./repository.hasonerepository.get.md)
## HasOneRepository.get() method
Find the only target model instance that belongs to the declaring model.
**Signature:**
```typescript
get(filter?: Pick<Filter<Target>, Exclude<keyof Filter<Target>, 'where'>>, options?: Options & {
polymorphicType?: string | string[];
}): Promise<Target>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| filter | Pick<[Filter](./filter.filter.md)<!-- --><Target>, Exclude<keyof [Filter](./filter.filter.md)<!-- --><Target>, 'where'>> | _(Optional)_ Query filter without a Where condition |
| options | [Options](./repository.options.md) & { 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 |
**Returns:**
Promise<Target>
A promise resolved with the target object or rejected with an EntityNotFoundError when target model instance was not found.