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

export interface IQuestion {
Jiwon Yoon's avatar
Jiwon Yoon committed
4
  _id?: Types.ObjectId;
Jiwon Yoon's avatar
Jiwon Yoon committed
5
  user?: Types.ObjectId;
Jiwon Yoon's avatar
Jiwon Yoon committed
6
7
8
9
10
11
12
13
14
  type: string;
  title?: string;
  isRequired: boolean;
  comment?: string;
  content?: any;
}

const schema = new Schema<IQuestion>(
  {
Jiwon Yoon's avatar
Jiwon Yoon committed
15
    user: { type: Schema.Types.ObjectId, ref: "User" },
Jiwon Yoon's avatar
Jiwon Yoon committed
16
17
18
19
20
21
22
23
24
25
    type: { type: String },
    title: { type: String },
    isRequired: { type: Boolean },
    comment: { type: String },
    content: { type: Object },
  },
  {
    toJSON: {
      versionKey: false,
    },
Jiwon Yoon's avatar
Jiwon Yoon committed
26
  }
Jiwon Yoon's avatar
Jiwon Yoon committed
27
28
29
);

export default model<IQuestion>("Question", schema);