aboutsummaryrefslogtreecommitdiff
path: root/models/feedback/feedback.schema.ts
blob: a0844d6ac46118563f84e619fa4ee7213bf27036 (plain)
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
import { Document, Schema, Types } from 'mongoose';

export interface FeedbackSchema extends Document {
  contents: string;
  authorId: string;
  score: number;
  version: string;
  createdAt: Date;
}

export const FeedbackSchema = new Schema({
  contents: String,
  authorId: {
    type: Types.ObjectId,
    required: true,
    ref: 'User'
  },
  score: {
    type: Number,
    required: true
  },
  version: {
    type: String,
    match: /^v\d+\.\d+\.\d+$/,
    required: true
  }
}, { timestamps: true });