@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
43 lines (27 loc) • 1.62 kB
Markdown
---
lang: en
title: 'API docs: repository.entitycrudrepository.findbyid'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/strongloop/loopback-next/tree/master/packages/repository
permalink: /doc/en/lb4/apidocs.repository.entitycrudrepository.findbyid.html
---
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/repository](./repository.md) > [EntityCrudRepository](./repository.entitycrudrepository.md) > [findById](./repository.entitycrudrepository.findbyid.md)
## EntityCrudRepository.findById() method
Find an entity by id, return a rejected promise if not found.
<b>Signature:</b>
```typescript
findById(id: ID, filter?: FilterExcludingWhere<T>, options?: Options): Promise<T & Relations>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| id | ID | Value for the entity id |
| filter | [FilterExcludingWhere](./filter.filterexcludingwhere.md)<!-- --><T> | Additional query options. E.g. <code>filter.include</code> configures which related models to fetch as part of the database query (or queries). |
| options | [Options](./repository.options.md) | Options for the operations |
<b>Returns:</b>
Promise<T & Relations>
A promise of an entity found for the id
## Remarks
The rationale behind findById is to find an instance by its primary key (id). No other search criteria than id should be used. If a client wants to use a `where` clause beyond id, use `find` or `findOne` instead.