Skip to content

Commit 15189ee

Browse files
committed
fix(example-express-composition): allow partial updates via PATCH
Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
1 parent cff8189 commit 15189ee

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

examples/express-composition/src/controllers/note.controller.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
del,
1515
get,
1616
getFilterSchemaFor,
17+
getModelSchemaRef,
1718
getWhereSchemaFor,
1819
param,
1920
patch,
@@ -84,7 +85,14 @@ export class NoteController {
8485
},
8586
})
8687
async updateAll(
87-
@requestBody() note: Note,
88+
@requestBody({
89+
content: {
90+
'application/json': {
91+
schema: getModelSchemaRef(Note, {partial: true}),
92+
},
93+
},
94+
})
95+
note: Partial<Note>,
8896
@param.query.object('where', getWhereSchemaFor(Note)) where?: Where<Note>,
8997
): Promise<Count> {
9098
return await this.noteRepository.updateAll(note, where);
@@ -111,7 +119,14 @@ export class NoteController {
111119
})
112120
async updateById(
113121
@param.path.number('id') id: number,
114-
@requestBody() note: Note,
122+
@requestBody({
123+
content: {
124+
'application/json': {
125+
schema: getModelSchemaRef(Note, {partial: true}),
126+
},
127+
},
128+
})
129+
note: Partial<Note>,
115130
): Promise<void> {
116131
await this.noteRepository.updateById(id, note);
117132
}

0 commit comments

Comments
 (0)