add:module:user:*update | add all service in module user for updating data
This commit is contained in:
@ -1,18 +1,19 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { userModel } from "../user.model";
|
||||
|
||||
export const checkUserEmailAndUsernameAvailabillity = async (
|
||||
payload: Partial<Prisma.UserGetPayload<Record<string, never>>>
|
||||
export const checkUserEmailAndUsernameAvailabillityRepo = async (
|
||||
id: string,
|
||||
username: string,
|
||||
email: string
|
||||
) => {
|
||||
try {
|
||||
const checkUsernameAndEmailAvailabillity = await userModel.findFirst({
|
||||
where: {
|
||||
OR: [
|
||||
{ username: payload.username ?? undefined },
|
||||
{ email: payload.email ?? undefined },
|
||||
{ username: username ?? undefined },
|
||||
{ email: email ?? undefined },
|
||||
],
|
||||
NOT: {
|
||||
id: payload.id,
|
||||
id: id,
|
||||
},
|
||||
},
|
||||
});
|
||||
@ -1,20 +1,17 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { userModel } from "../user.model";
|
||||
import { JWTSessionPayload } from "../../auth/auth.types";
|
||||
|
||||
export const updateUserRepo = async (
|
||||
identifier: string,
|
||||
payload: Prisma.UserUncheckedCreateInput
|
||||
username: string,
|
||||
payload: Prisma.UserUpdateInput
|
||||
) => {
|
||||
try {
|
||||
const userData = await userModel.update({
|
||||
where: {
|
||||
username: identifier,
|
||||
},
|
||||
data: {
|
||||
username: payload.username,
|
||||
name: payload.name,
|
||||
birthDate: payload.name,
|
||||
username,
|
||||
},
|
||||
data: payload,
|
||||
});
|
||||
return userData;
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user