diff --git a/src/rts/rts.service.ts b/src/rts/rts.service.ts index 206ea0c..040bd3a 100644 --- a/src/rts/rts.service.ts +++ b/src/rts/rts.service.ts @@ -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) {