feat: also remove file when delete data

This commit is contained in:
Methapon Metanipat 2024-09-05 15:06:00 +07:00
parent 277860805b
commit 185de6eda8

View file

@ -616,6 +616,8 @@ export class BranchController extends Controller {
province: true,
district: true,
subDistrict: true,
contact: true,
bank: true,
createdBy: true,
updatedBy: true,
},
@ -637,6 +639,14 @@ export class BranchController extends Controller {
minio.removeObject(MINIO_BUCKET, fileLocation.branch.image(branchId), {
forceDelete: true,
}),
minio.removeObject(MINIO_BUCKET, fileLocation.branch.map(branchId), {
forceDelete: true,
}),
...data.bank.map(async (v) => {
await minio.removeObject(MINIO_BUCKET, fileLocation.branch.bank(branchId, v.id), {
forceDelete: true,
});
}),
]);
return data;