* 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>)
| 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`. |
no test coverage detected