Skip to content

Commit

Permalink
fix(example-express-composition): allow partial updates via PATCH
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
  • Loading branch information
bajtos committed Jun 25, 2019
1 parent cff8189 commit 15189ee
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions examples/express-composition/src/controllers/note.controller.ts
Expand Up @@ -14,6 +14,7 @@ import {
del,
get,
getFilterSchemaFor,
getModelSchemaRef,
getWhereSchemaFor,
param,
patch,
Expand Down Expand Up @@ -84,7 +85,14 @@ export class NoteController {
},
})
async updateAll(
@requestBody() note: Note,
@requestBody({
content: {
'application/json': {
schema: getModelSchemaRef(Note, {partial: true}),
},
},
})
note: Partial<Note>,
@param.query.object('where', getWhereSchemaFor(Note)) where?: Where<Note>,
): Promise<Count> {
return await this.noteRepository.updateAll(note, where);
Expand All @@ -111,7 +119,14 @@ export class NoteController {
})
async updateById(
@param.path.number('id') id: number,
@requestBody() note: Note,
@requestBody({
content: {
'application/json': {
schema: getModelSchemaRef(Note, {partial: true}),
},
},
})
note: Partial<Note>,
): Promise<void> {
await this.noteRepository.updateById(id, note);
}
Expand Down

0 comments on commit 15189ee

Please sign in to comment.