From 3fab49e3a8259b8986dfc55072d0d732a26f09d5 Mon Sep 17 00:00:00 2001 From: Akhil Meka Date: Sat, 17 May 2025 10:06:28 +0530 Subject: [PATCH] rts create bug fix --- src/rts/rts.service.ts | 6 ++---- src/user/user.service.ts | 4 ++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/rts/rts.service.ts b/src/rts/rts.service.ts index 72f21ee..206ea0c 100644 --- a/src/rts/rts.service.ts +++ b/src/rts/rts.service.ts @@ -8,9 +8,7 @@ import { import { AuthenticatedUser } from "../auth"; import { generateId } from "../utils/id"; import { getFilterObject, getSortObject, PageQueryParams } from "../pagination"; -import { getUser } from "../user/user.service"; -import { orgModel } from "../organization/organization.schema"; -import { userModel } from "../user/user.schema"; +import { getUserWithoutPopulate } from "../user/user.service"; import mongoose from "mongoose"; export async function createRts( @@ -18,7 +16,7 @@ export async function createRts( user: AuthenticatedUser ) { let defaultClient = input.client; - const userInDb = await getUser(user.userId); + const userInDb = await getUserWithoutPopulate(user.userId); if (userInDb && userInDb.orgId) { defaultClient = userInDb.orgId.toString(); } diff --git a/src/user/user.service.ts b/src/user/user.service.ts index 597ec44..e5a8cc2 100644 --- a/src/user/user.service.ts +++ b/src/user/user.service.ts @@ -71,6 +71,10 @@ export async function getUser(userId: string) { .populate({ path: "orgId", select: "_id pid name" }); } +export async function getUserWithoutPopulate(userId: string) { + return await userModel.findById(userId); +} + export async function getUserByToken(token: string) { return await userModel.findOne({ "token.value": token }); }