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

Method deleteOne

libs/common/src/TypegooseQueryService.ts:295–301  ·  view source on GitHub ↗

* Delete an entity by `id`. * * @example * * ```ts * const deletedTodo = await this.service.deleteOne(1); * ``` * * @param id - The `id` of the entity to delete. * @param opts - Additional filter to use when finding the entity to delete.

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

Source from the content-addressed store, hash-verified

293 * @param opts - Additional filter to use when finding the entity to delete.
294 */
295 async deleteOne(id: string, opts?: DeleteOneOptions<Entity>): Promise<Entity> {
296 const doc = await this.Model.findOneAndDelete(this.mergeFilterWithId(id, opts?.filter))
297 if (doc) {
298 return doc.toObject(this.documentToObjectOptions) as Entity
299 }
300 throw new NotFoundException(`Unable to find ${this.Model.modelName} with id: ${id}`)
301 }
302
303 /**
304 * Delete multiple records with a `@ptc-org/nestjs-query-core` `Filter`.

Callers 2

runMethod · 0.45
deleteOneNativeFunction · 0.45

Calls 1

mergeFilterWithIdMethod · 0.95

Tested by

no test coverage detected