aboutsummaryrefslogtreecommitdiff
path: root/models/votes/vote.schema.ts
blob: 63ba21284f3408d3b5115f748b81095c31741224 (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
import { Document, Schema, Types } from 'mongoose';
import { Vote } from 'which-types';

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

export const voteSchema = new Schema({
  userId: {
    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 });