diff options
author | eug-vs <eug-vs@keemail.me> | 2020-06-25 08:56:47 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-06-25 08:56:47 +0300 |
commit | ffcb9d248228087ee05c7569784705b41d729aee (patch) | |
tree | d753ff19df916a283991b3f9baf668df501cdfff /models/votes/vote.schema.ts | |
parent | 75e527334e4e9a94b63704f87aa650c75f13891c (diff) | |
download | which-api-ffcb9d248228087ee05c7569784705b41d729aee.tar.gz |
feat: create vote model
Diffstat (limited to 'models/votes/vote.schema.ts')
-rw-r--r-- | models/votes/vote.schema.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/models/votes/vote.schema.ts b/models/votes/vote.schema.ts new file mode 100644 index 0000000..36b38f2 --- /dev/null +++ b/models/votes/vote.schema.ts @@ -0,0 +1,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 }); + |