Patch: Throw 404 if row not found

This commit is contained in:
Mel O'Hagan 2022-10-27 17:52:28 +01:00
parent 7f1b81dd7a
commit 5fc8299390
2 changed files with 4 additions and 3 deletions

View File

@ -286,9 +286,7 @@ module External {
if (isNaN(id)) {
id = decodeURIComponent(row[key]).match(/\[(.*?)\]/)?.[1]
}
newRow[field.foreignKey || linkTablePrimary] = breakRowIdField(
id
)[0]
newRow[field.foreignKey || linkTablePrimary] = breakRowIdField(id)[0]
}
// many to many
else if (field.through) {

View File

@ -37,6 +37,9 @@ export async function patch(ctx: any): Promise<any> {
datasourceId: tableId,
}
)
if (!row) {
ctx.throw(404, "Row not found!")
}
ctx.status = 200
ctx.eventEmitter &&
ctx.eventEmitter.emitRow(`row:update`, appId, row, table)