🏗️ reconstruct all system in user module
This commit is contained in:
@ -1,17 +0,0 @@
|
||||
import { userModel } from "../user.model";
|
||||
|
||||
export const checkUserEmailAndUsernameAvailabillityRepo = async (
|
||||
id: string,
|
||||
username: string,
|
||||
email: string
|
||||
) => {
|
||||
const checkUsernameAndEmailAvailabillity = await userModel.findFirst({
|
||||
where: {
|
||||
OR: [{ username: username ?? undefined }, { email: email ?? undefined }],
|
||||
NOT: {
|
||||
id: id,
|
||||
},
|
||||
},
|
||||
});
|
||||
return checkUsernameAndEmailAvailabillity;
|
||||
};
|
||||
@ -0,0 +1,10 @@
|
||||
import { userModel } from "../../user.model";
|
||||
import { createUserViaRegisterInput } from "../../user.types";
|
||||
|
||||
export const createUserViaRegisterRepository = async (
|
||||
payload: createUserViaRegisterInput
|
||||
) => {
|
||||
return await userModel.create({
|
||||
data: payload,
|
||||
});
|
||||
};
|
||||
@ -1,13 +0,0 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { userModel } from "../user.model";
|
||||
|
||||
export const createUserRepo = async (data: Prisma.UserCreateInput) => {
|
||||
const userData = await userModel.create({
|
||||
data,
|
||||
omit: {
|
||||
password: true,
|
||||
},
|
||||
});
|
||||
|
||||
return userData;
|
||||
};
|
||||
@ -1,28 +0,0 @@
|
||||
import { userModel } from "../user.model";
|
||||
import { FindUserByEmailOrUsernameOptions } from "../user.types";
|
||||
|
||||
export const findUserByEmailOrUsernameRepository = async (
|
||||
identifier: string,
|
||||
options: FindUserByEmailOrUsernameOptions
|
||||
) => {
|
||||
const userData = await userModel.findUnique({
|
||||
where: { email: identifier },
|
||||
include: {
|
||||
assignedRoles: {
|
||||
select: {
|
||||
role: {
|
||||
omit: {
|
||||
createdBy: true,
|
||||
updatedAt: true,
|
||||
createdAt: true,
|
||||
deletedAt: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!userData) return false;
|
||||
return userData;
|
||||
};
|
||||
@ -1,11 +0,0 @@
|
||||
import { userModel } from "../user.model";
|
||||
|
||||
export const getAllUserRepo = async () => {
|
||||
const data = await userModel.findMany({
|
||||
where: {
|
||||
deletedAt: null,
|
||||
},
|
||||
});
|
||||
|
||||
return data;
|
||||
};
|
||||
@ -1,16 +0,0 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { userModel } from "../user.model";
|
||||
|
||||
export const updateUserRepository = async (
|
||||
username: string,
|
||||
payload: Prisma.UserUpdateInput
|
||||
) => {
|
||||
const userData = await userModel.update({
|
||||
where: {
|
||||
username,
|
||||
},
|
||||
data: payload,
|
||||
});
|
||||
|
||||
return userData;
|
||||
};
|
||||
Reference in New Issue
Block a user