add user route

This commit is contained in:
2025-02-05 16:22:40 +05:30
parent 2d62e9712b
commit 42d68615d2
3 changed files with 42 additions and 3 deletions

View File

@@ -1,3 +1,4 @@
import mongoose from "mongoose";
import { generateId } from "../utils/id";
import { CreateUserInput, UpdateUserInput, userModel } from "./user.schema";
@@ -14,10 +15,13 @@ export async function createUser(input: CreateUserInput, tenantId: string) {
}
export async function getUser(userId: string) {
const user = await userModel.findOne({
if (mongoose.Types.ObjectId.isValid(userId)) {
return await userModel.findById(userId);
}
return await userModel.findOne({
$and: [{ pid: userId }],
});
return user;
}
export async function getUserByEmail(email: string) {