aboutsummaryrefslogtreecommitdiff
path: root/models/votes/vote.schema.ts
blob: d8128b320dece80923d0192e553546447b4c490e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { Document, Schema, Types } from 'mongoose';
import { Vote } from 'which-types';

export interface VoteSchema extends Document, Omit<Vote, '_id'> {};

export const voteSchema = new Schema({
  authorId: {
    type: Types.ObjectId,
    ref: 'user',
    required: true
  },
  pollId: {
    type: Types.ObjectId,
    ref: 'poll',
    required: true
  },
  which: {
    type: String,
    enum: ['left', 'right'],
    required: true
  }
}, { timestamps: true });