aboutsummaryrefslogtreecommitdiff
path: root/models/votes/vote.schema.ts
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-06-25 11:23:20 +0300
committereug-vs <eug-vs@keemail.me>2020-06-25 11:23:20 +0300
commita58354a1d1bf967fc932723b9138d8c6322591d5 (patch)
tree19ae1b05bed540af43dbcc93803f2704efbcf604 /models/votes/vote.schema.ts
parent681e51a658bfed723b368fc5b71b1350909d9496 (diff)
downloadwhich-api-a58354a1d1bf967fc932723b9138d8c6322591d5.tar.gz
feat: validate fields in votes
Diffstat (limited to 'models/votes/vote.schema.ts')
-rw-r--r--models/votes/vote.schema.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/models/votes/vote.schema.ts b/models/votes/vote.schema.ts
index 709e8bf..63ba212 100644
--- a/models/votes/vote.schema.ts
+++ b/models/votes/vote.schema.ts
@@ -8,15 +8,18 @@ export interface VoteSchema extends Document, Omit<Vote, '_id'> {
export const voteSchema = new Schema({
userId: {
type: Types.ObjectId,
- ref: 'user'
+ ref: 'user',
+ required: true
},
pollId: {
type: Types.ObjectId,
- ref: 'poll'
+ ref: 'poll',
+ required: true
},
which: {
type: String,
- enum: ['left', 'right']
+ enum: ['left', 'right'],
+ required: true
}
}, { timestamps: true });