* Find an entity by it's `id`. * * @example * ```ts * const todoItem = await this.service.findById(1); * ``` * @param id - The id of the record to find. * @param opts - Additional options
(id: string, opts?: FindByIdOptions<Entity>)
| 173 | * @param opts - Additional options |
| 174 | */ |
| 175 | async findById(id: string, opts?: FindByIdOptions<Entity>): Promise<Entity | undefined> { |
| 176 | const doc = await this.Model.findOne(this.mergeFilterWithId(id, opts?.filter)) |
| 177 | return (doc as any)?.toObject(this.documentToObjectOptions) as Entity |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * Gets an entity by it's `id`. If the entity is not found a rejected promise is returned. |
no test coverage detected