aboutsummaryrefslogtreecommitdiff
path: root/models/polls/poll.schema.ts
blob: 79036c38e2954b3e113728bcf1b214ee83bf3d41 (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
29
30
31
32
import { Document, Schema, Types } from 'mongoose';

interface ImageData {
  url: string;
  votes: number;
}

export interface PollSchema extends Document {
  authorId: string;
  contents: {
    left: ImageData;
    right: ImageData;
  };
}


const imageDataSchema = {
  url: String,
  votes: Number
}

export const pollSchema = new Schema({
  contents: {
    left: imageDataSchema,
    right: imageDataSchema
  },
  authorId: { 
    type: Types.ObjectId,
    ref: 'User'
  }
});