Page Contents

Home > @loopback/repository > EntityCrudRepository > findById

EntityCrudRepository.findById() method

Find an entity by id, return a rejected promise if not found.


findById(id: ID, filter?: FilterExcludingWhere<T>, options?: Options): Promise<T & Relations>;


Parameter Type Description
id ID Value for the entity id
filter FilterExcludingWhere<T> (Optional) Additional query options. E.g. filter.include configures which related models to fetch as part of the database query (or queries).
options Options (Optional) Options for the operations


Promise<T & Relations>

A promise of an entity found for the id


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.