mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
24 lines
509 B
TypeScript
24 lines
509 B
TypeScript
"use server";
|
|
|
|
import { revalidatePath } from "next/cache";
|
|
|
|
import { db } from "@/lib/turso";
|
|
|
|
export const addTodo = async (formData: FormData) => {
|
|
await db.execute({
|
|
sql: "INSERT INTO todos (description) VALUES (?)",
|
|
args: [formData.get("description") as string],
|
|
});
|
|
|
|
revalidatePath("/");
|
|
};
|
|
|
|
export const removeTodo = async (formData: FormData) => {
|
|
await db.execute({
|
|
sql: "DELETE FROM todos WHERE id = ?",
|
|
args: [formData.get("id") as string],
|
|
});
|
|
|
|
revalidatePath("/");
|
|
};
|