aboutsummaryrefslogtreecommitdiff
path: root/models/votes/vote.schema.ts
blob: 36b38f241cad4b5e4b26b405569cdb7b43882221 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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'
  },
  pollId: {
    type: Types.ObjectId,
    ref: 'poll'
  },
  which: {
    type: String,
    match: /left|right/g
  }
}, { timestamps: true });