refactor: delete institution
This commit is contained in:
parent
fec6bd8c75
commit
2a6cb6ddc0
1 changed files with 5 additions and 3 deletions
|
|
@ -96,13 +96,15 @@ export class InstitutionController extends Controller {
|
||||||
@Security("keycloak")
|
@Security("keycloak")
|
||||||
async deleteInstitution(@Path() institutionId: string) {
|
async deleteInstitution(@Path() institutionId: string) {
|
||||||
return await prisma.$transaction(async (tx) => {
|
return await prisma.$transaction(async (tx) => {
|
||||||
const ret = await tx.institution.deleteMany({
|
const record = await tx.institution.findFirst({
|
||||||
where: { id: institutionId },
|
where: { id: institutionId },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (ret.count <= 0) throw notFoundError("Institution");
|
if (!record) throw notFoundError("Institution");
|
||||||
|
|
||||||
return ret;
|
return await tx.institution.delete({
|
||||||
|
where: { id: institutionId },
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue