import {db} from '@/lib/db/prisma/client'
import {toInt} from '@/lib/utils'

export const getUsers = async () => await db.user.findMany()

export const getAllUsers = await db.user.findMany()
export const getUserById = async (id: unknown) => {
	id = toInt(id)
	if (!id) return null

	try {
		return await db.user.findUnique({
			where: {
				id: parseInt(id as string)
			}
		})
	} catch (error) {
		console.log(error)
		return null
	}
}
