refactored orm operations in components to server actions
All checks were successful
Vercel Preview Deployment / Deploy-Preview (push) Successful in 1m13s

This commit is contained in:
ChrQR 2024-06-03 13:38:20 +02:00
parent 54454aad6d
commit 4b554cdb37
4 changed files with 18 additions and 5 deletions

View File

@ -1,9 +1,9 @@
import { Delete } from "lucide-react";
import { deleteCountry } from "~/server/actions/deleteCountry";
import { db } from "~/server/db";
import getAllCountries from "~/server/actions/getAllCountries";
export default async function AllCountries() {
const countries = await db.query.countries.findMany();
const countries = await getAllCountries();
return (
<div className="pt-4">
<h1 className="text-2xl">All Countries:</h1>

View File

@ -1,8 +1,9 @@
import { db } from "~/server/db";
import getAllCountries from "~/server/actions/getAllCountries";
import getAllRegions from "~/server/actions/getAllRegions";
export default async function AllRegions() {
const allRegions = await db.query.regions.findMany();
const allCountries = await db.query.countries.findMany();
const allRegions = await getAllRegions();
const allCountries = await getAllCountries();
return (
<div className="pt-4">
<h1 className="text-2xl">All Regions:</h1>

View File

@ -0,0 +1,6 @@
import { db } from "../db";
export default async function getAllCountries() {
const allCountries = await db.query.countries.findMany();
return allCountries;
}

View File

@ -0,0 +1,6 @@
import { db } from "../db";
export default async function getAllRegions() {
const allRegions = await db.query.regions.findMany();
return allRegions;
}