MCPcopy Create free account
hub / github.com/chainjet/platform / getById

Method getById

libs/common/src/TypegooseQueryService.ts:194–200  ·  view source on GitHub ↗

* Gets an entity by it's `id`. If the entity is not found a rejected promise is returned. * * @example * ```ts * try { * const todoItem = await this.service.getById(1); * } catch(e) { * console.error('Unable to find entity with id = 1'); * } * ``` * @param id - The

(id: string, opts?: GetByIdOptions<Entity>)

Source from the content-addressed store, hash-verified

192 * @param opts - Additional options
193 */
194 async getById(id: string, opts?: GetByIdOptions<Entity>): Promise<Entity> {
195 const entity = await this.findById(id, opts)
196 if (!entity) {
197 throw new NotFoundException(`Unable to find ${this.Model.modelName} with id: ${id}`)
198 }
199 return entity
200 }
201
202 /**
203 * Creates a single entity.

Callers

nothing calls this directly

Calls 1

findByIdMethod · 0.95

Tested by

no test coverage detected