Page Contents
Home > @loopback/repository > EntityCrudRepository > findById
EntityCrudRepository.findById() method
Find an entity by id, return a rejected promise if not found.
Signature:
findById(id: ID, filter?: FilterExcludingWhere<T>, options?: Options): Promise<T & Relations>;
Parameters
Parameter | Type | Description |
---|---|---|
id | ID | Value for the entity id |
filter | FilterExcludingWhere<T> | Additional query options. E.g. filter.include configures which related models to fetch as part of the database query (or queries). |
options | Options | Options for the operations |
Returns:
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.