Files
learn-languages/src/lib/actions/services/textPairService.ts
goddonebianu 0bf3b718b2
All checks were successful
continuous-integration/drone/push Build is passing
...
2025-11-17 15:59:35 +08:00

52 lines
973 B
TypeScript

"use server";
import {
text_pairCreateInput,
text_pairUpdateInput,
} from "../../../../generated/prisma/models";
import prisma from "../../db";
export async function createTextPair(data: text_pairCreateInput) {
await prisma.text_pair.create({
data: data,
});
}
export async function deleteTextPairById(id: number) {
await prisma.text_pair.delete({
where: {
id: id,
},
});
}
export async function updateTextPairById(
id: number,
data: text_pairUpdateInput,
) {
await prisma.text_pair.update({
where: {
id: id,
},
data: data,
});
}
export async function getTextPairCountByFolderId(folderId: number) {
const count = await prisma.text_pair.count({
where: {
folder_id: folderId,
},
});
return count;
}
export async function getTextPairsByFolderId(folderId: number) {
const textPairs = await prisma.text_pair.findMany({
where: {
folder_id: folderId,
},
});
return textPairs;
}