answer.model.ts 510 Bytes
Newer Older
Jiwon Yoon's avatar
Jiwon Yoon committed
1
2
import { model, Schema, Types } from "mongoose";

3
export interface IAnswer {
Jiwon Yoon's avatar
Jiwon Yoon committed
4
5
6
  _id?: Types.ObjectId;
  surveyId?: Types.ObjectId;
  questionId?: Types.ObjectId;
7
  guestId?: string;
Jiwon Yoon's avatar
Jiwon Yoon committed
8
9
10
  answer?: any;
}

11
const schema = new Schema<IAnswer>(
Jiwon Yoon's avatar
Jiwon Yoon committed
12
13
14
  {
    surveyId: { type: Schema.Types.ObjectId, ref: "Survey" },
    questionId: { type: Schema.Types.ObjectId, ref: "Question" },
15
    guestId: { type: String },
Jiwon Yoon's avatar
Jiwon Yoon committed
16
17
18
19
20
    answer: { type: Object },
  },
  { timestamps: true }
);

21
export default model<IAnswer>("Answer", schema);