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")
|
||||
async deleteInstitution(@Path() institutionId: string) {
|
||||
return await prisma.$transaction(async (tx) => {
|
||||
const ret = await tx.institution.deleteMany({
|
||||
const record = await tx.institution.findFirst({
|
||||
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