return populated fields on rts create

This commit is contained in:
2025-05-17 10:09:17 +05:30
parent 3fab49e3a8
commit bd4d6363d0

View File

@@ -21,7 +21,7 @@ export async function createRts(
defaultClient = userInDb.orgId.toString();
}
return await rtsModel.create({
const newRts = await rtsModel.create({
...input,
tenantId: user.tenantId,
pid: generateId(),
@@ -29,6 +29,13 @@ export async function createRts(
createdAt: new Date(),
createdBy: user.userId ?? null,
});
return rtsModel
.findById(newRts.id)
.populate({ path: "county", select: "pid name avatar" })
.populate({ path: "client", select: "pid name avatar" })
.populate({ path: "createdBy", select: "pid name avatar" })
.populate({ path: "assignedTo", select: "pid name avatar" });
}
export async function getRts(id: string, tenantId: string) {