import { Prisma } from "@prisma/client"
import { prisma } from "./prisma-client"

// Create a new app installation
export async function createAppInstallation(data: Prisma.cf_app_installationsCreateInput) {
  return await prisma.cf_app_installations.create({ data })
}

// Read (get) a single app installation by ID
export async function getAppInstallationById(id: string) {
  return await prisma.cf_app_installations.findUnique({
    where: { id },
  })
}
// Read (get) a single app installation by ID
export async function getAppInstallationByInstalltionId(installation_id: number) {
  return await prisma.cf_app_installations.findUnique({
    where: { installation_id: installation_id },
  })
}

// Read all app installations
export async function getAllAppInstallations() {
  return await prisma.cf_app_installations.findMany()
}

// Update an app installation by ID
export async function updateAppInstallation(
  id: string,
  data: Prisma.cf_app_installationsUpdateInput,
) {
  return await prisma.cf_app_installations.update({
    where: { id },
    data,
  })
}

// Delete an app installation by ID
export async function deleteAppInstallation(id: string) {
  return await prisma.cf_app_installations.delete({
    where: { id },
  })
}
