feat: auto update clientData field when client field is updated for permits and processed permits
This commit is contained in:
@@ -235,7 +235,6 @@ export async function updatePermit(
|
||||
{ new: true }
|
||||
)
|
||||
.populate({ path: "county", select: "pid name avatar" })
|
||||
.populate({ path: "client", select: "pid name avatar" })
|
||||
.populate({ path: "assignedTo", select: "pid name avatar" })
|
||||
.populate({ path: "createdBy", select: "pid name avatar" });
|
||||
|
||||
@@ -274,6 +273,19 @@ export async function updatePermit(
|
||||
"permits"
|
||||
);
|
||||
}
|
||||
} else if (key == "client") {
|
||||
const orgInDb = await orgModel.findById(input.client);
|
||||
if (orgInDb) {
|
||||
updatePermitResult.clientData = {
|
||||
pid: orgInDb.pid,
|
||||
licenseNumber: orgInDb.licenseNumber,
|
||||
name: orgInDb.name,
|
||||
avatar: orgInDb.avatar,
|
||||
};
|
||||
|
||||
updatePermitResult.markModified("clientData");
|
||||
await updatePermitResult.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user