@Patch()
Maps a controller method to an HTTP PATCH request for the given path.
Syntax
@Patch(path?: string | string[]) Parameters
| Name | Type | Required | Description |
|---|---|---|---|
path | string | string[] | No | Optional route path appended to the controller prefix. |
Returns
MethodDecorator — A decorator applied to the route handler method.
Examples
import { Controller, Patch, Param, Body } from '@nestjs/common';
@Controller('cats')
export class CatsController {
@Patch(':id')
update(@Param('id') id: string, @Body() dto: Partial<{ name: string }>) {
return { id, ...dto };
}
}
Notes
PATCH applies a partial modification to a resource. Combine with a DTO of
optional fields and the ValidationPipe to safely accept subsets of data.