Files
bewell-in-ua/actions/auth/common.ts
2025-02-05 08:01:14 +02:00

22 lines
594 B
TypeScript

'use server'
import {getUserWithAccount} from '@prisma/client/sql'
import {getAccountByUserId} from '@/data/accout'
import {getUserById} from '@/data/user'
import {db} from '@/lib/db/prisma/client'
export const exisingUser = async (id: string | number) => {
return await getUserById(id)
}
export const exisingUserAccount = async (userId: string | number) => {
return await getAccountByUserId(userId)
}
export const getUserAccountByUserId = async (userId: string | number) => {
const user = await db.$queryRawTyped(getUserWithAccount(userId))
return user.length > 0 ? user[0] : null
}