question.db.ts 527 Bytes
Newer Older
Jiwon Yoon's avatar
Jiwon Yoon committed
1
2
3
4
import { Question, IQuestion } from "../models";

export const createQuestion = async (question: IQuestion) => {
  const newQuestion = await Question.create(question);
Jiwon Yoon's avatar
Jiwon Yoon committed
5
  return newQuestion;
Jiwon Yoon's avatar
Jiwon Yoon committed
6
};
Jiwon Yoon's avatar
Jiwon Yoon committed
7
8
9
10
11
12
13
14
15
16
17

export const updateQuestion = async (question: IQuestion) => {
  const id = question._id;
  const newQuestion = await Question.findOneAndUpdate({ _id: id }, question);
  return newQuestion;
};

export const deleteQuestion = async (id: string) => {
  const newQuestion = await Question.findByIdAndDelete(id);
  return newQuestion;
};