-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathquestion.service.ts
More file actions
48 lines (44 loc) · 1.07 KB
/
question.service.ts
File metadata and controls
48 lines (44 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import prisma from "../db/client";
import { Difficulty } from "../generated/prisma/enums";
export const getQuestionByTopicId = async (TopicId: number) => {
return await prisma.question.findMany({
where: { topicId: TopicId },
});
};
export const getQuestionByQuestionId = async (questionId: number) => {
return await prisma.question.findUnique({
where: { id: questionId },
});
};
export const addQuestionByTopicId = async (
adminId: string,
TopicId: number,
link: string,
difficulty: Difficulty,
questionName: string,
) => {
return await prisma.question.create({
data: {
questionName,
difficulty,
link,
topicId: TopicId,
createdById: adminId,
updatedById: adminId,
},
});
};
export const updateQuestion = async (
questionData: questionData,
questionId: number,
) => {
return await prisma.question.update({
where: { id: questionId },
data: questionData,
});
};
export const deleteQuestion = async (questionId: number) => {
return await prisma.question.delete({
where: { id: questionId },
});
};