diff --git a/docs/site/Controller-generator.md b/docs/site/Controller-generator.md index 505f16ce09d1..671d493d67e1 100644 --- a/docs/site/Controller-generator.md +++ b/docs/site/Controller-generator.md @@ -168,7 +168,7 @@ export class TodoController { }, }) async updateAll( - @requestBody() data: Todo, + @requestBody() data: Partial, @param.query.object('where', getWhereSchemaFor(Todo)) where?: Where, ): Promise { return await this.todoRepository.updateAll(data, where); @@ -195,7 +195,7 @@ export class TodoController { }) async updateById( @param.path.number('id') id: number, - @requestBody() data: Todo, + @requestBody() data: Partial, ): Promise { await this.todoRepository.updateById(id, data); } diff --git a/docs/site/todo-list-tutorial-controller.md b/docs/site/todo-list-tutorial-controller.md index d3c18830982c..4ba2a85de62d 100644 --- a/docs/site/todo-list-tutorial-controller.md +++ b/docs/site/todo-list-tutorial-controller.md @@ -197,7 +197,7 @@ export class TodoListController { }) async updateById( @param.path.number('id') id: number, - @requestBody() obj: TodoList, + @requestBody() obj: Partial, ): Promise { await this.todoListRepository.updateById(id, obj); } diff --git a/examples/todo-list/src/controllers/todo-list.controller.ts b/examples/todo-list/src/controllers/todo-list.controller.ts index fa0bc5c0886f..2b57dee4c8ea 100644 --- a/examples/todo-list/src/controllers/todo-list.controller.ts +++ b/examples/todo-list/src/controllers/todo-list.controller.ts @@ -105,7 +105,7 @@ export class TodoListController { }) async updateById( @param.path.number('id') id: number, - @requestBody() obj: TodoList, + @requestBody() obj: Partial, ): Promise { await this.todoListRepository.updateById(id, obj); } diff --git a/examples/todo-list/src/controllers/todo.controller.ts b/examples/todo-list/src/controllers/todo.controller.ts index 5d6a8a5ab33e..96c56c604ec4 100644 --- a/examples/todo-list/src/controllers/todo.controller.ts +++ b/examples/todo-list/src/controllers/todo.controller.ts @@ -88,7 +88,7 @@ export class TodoController { }) async updateTodo( @param.path.number('id') id: number, - @requestBody() todo: Todo, + @requestBody() todo: Partial, ): Promise { await this.todoRepo.updateById(id, todo); } diff --git a/examples/todo/src/controllers/todo.controller.ts b/examples/todo/src/controllers/todo.controller.ts index 3cc8f8677ffa..84e2979f5709 100644 --- a/examples/todo/src/controllers/todo.controller.ts +++ b/examples/todo/src/controllers/todo.controller.ts @@ -101,7 +101,7 @@ export class TodoController { }) async updateTodo( @param.path.number('id') id: number, - @requestBody() todo: Todo, + @requestBody() todo: Partial, ): Promise { await this.todoRepo.updateById(id, todo); } diff --git a/packages/cli/generators/controller/templates/src/controllers/controller-rest-template.ts.ejs b/packages/cli/generators/controller/templates/src/controllers/controller-rest-template.ts.ejs index 54e64004e8fc..c7000b1ffc28 100644 --- a/packages/cli/generators/controller/templates/src/controllers/controller-rest-template.ts.ejs +++ b/packages/cli/generators/controller/templates/src/controllers/controller-rest-template.ts.ejs @@ -77,7 +77,7 @@ export class <%= className %>Controller { }, }) async updateAll( - @requestBody() <%= modelVariableName %>: <%= modelName %>, + @requestBody() <%= modelVariableName %>: Partial<<%= modelName %>>, @param.query.object('where', getWhereSchemaFor(<%= modelName %>)) where?: Where, ): Promise { return await this.<%= repositoryNameCamel %>.updateAll(<%= modelVariableName %>, where); @@ -104,7 +104,7 @@ export class <%= className %>Controller { }) async updateById( @param.path.<%= idType %>('id') id: <%= idType %>, - @requestBody() <%= modelVariableName %>: <%= modelName %>, + @requestBody() <%= modelVariableName %>: Partial<<%= modelName %>>, ): Promise { await this.<%= repositoryNameCamel %>.updateById(id, <%= modelVariableName %>); }