import { PrismaClient } from '@prisma/client'
import { config } from 'dotenv'
import path from 'path'

config({ path: path.resolve(process.cwd(), '.env.local') })

const prisma = new PrismaClient()

async function check() {
  try {
    const users = await prisma.user.count()
    console.log(`Users found: ${users}`)
    
    if (users > 0) {
      const firstUser = await prisma.user.findFirst()
      console.log(`Example user ID: ${firstUser?.id}`)
    } else {
      console.log("WARNING: User table is EMPTY!")
    }
    
    const businesses = await prisma.business.count()
    console.log(`Businesses found: ${businesses}`)
  } catch (error) {
    console.error("Error connecting to DB:", error)
  } finally {
    await prisma.$disconnect()
  }
}

check()
