'use server'

import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()

export const getTests = () => {
  return prisma.test.findMany()
}

export const insertTest = async (param) => {
  return prisma.test.create({
    data: {
      content: param,
    },
  })
}

export const getCanvasStateAll = () => {
  return prisma.canvas.findMany()
}

export const getCanvasState = () => {
  return prisma.canvas.findFirst({
    where: {
      loginId: 'test',
    },
    orderBy: {
      id: 'desc',
    },
  })
}

export const insertCanvasState = (param) => {
  return prisma.canvas.create({
    data: param,
  })
}
