feat: include relation response when create and delete
This commit is contained in:
parent
4e9b8dbb83
commit
44bf228081
1 changed files with 13 additions and 1 deletions
|
|
@ -127,6 +127,11 @@ export class BranchController extends Controller {
|
|||
const { provinceId, districtId, subDistrictId, headOfficeId, ...rest } = body;
|
||||
|
||||
return await prisma.branch.create({
|
||||
include: {
|
||||
province: true,
|
||||
district: true,
|
||||
subDistrict: true,
|
||||
},
|
||||
data: {
|
||||
...rest,
|
||||
isHeadOffice: headOfficeId === null,
|
||||
|
|
@ -198,7 +203,14 @@ export class BranchController extends Controller {
|
|||
|
||||
@Delete("{branchId}")
|
||||
async deleteBranch(@Path() branchId: string) {
|
||||
const record = await prisma.branch.findFirst({ where: { id: branchId } });
|
||||
const record = await prisma.branch.findFirst({
|
||||
include: {
|
||||
province: true,
|
||||
district: true,
|
||||
subDistrict: true,
|
||||
},
|
||||
where: { id: branchId },
|
||||
});
|
||||
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "Branch cannot be found.");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue