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

export interface ISurvey {
Jiwon Yoon's avatar
Jiwon Yoon committed
4
  _id?: Types.ObjectId;
Jiwon Yoon's avatar
Jiwon Yoon committed
5
6
  title?: string;
  comment?: string;
Jiwon Yoon's avatar
Jiwon Yoon committed
7
  user: Types.ObjectId;
Jiwon Yoon's avatar
Jiwon Yoon committed
8
9
10
11
12
13
  questions: Types.ObjectId[];
}

const schema = new Schema<ISurvey>({
  title: { type: String },
  comment: { type: String },
Jiwon Yoon's avatar
Jiwon Yoon committed
14
  user: { type: Schema.Types.ObjectId, ref: "User" },
Jiwon Yoon's avatar
Jiwon Yoon committed
15
16
17
18
  questions: [{ type: Schema.Types.ObjectId, ref: "Question" }],
});

export default model<ISurvey>("Survey", schema);