From 302a76985cef867f509a4180387cc45e934452d5 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sun, 28 Jun 2020 16:13:34 +0300 Subject: feat: improve votes --- models/votes/vote.model.ts | 2 +- models/votes/vote.schema.ts | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'models') diff --git a/models/votes/vote.model.ts b/models/votes/vote.model.ts index df2307e..bf2dcf6 100644 --- a/models/votes/vote.model.ts +++ b/models/votes/vote.model.ts @@ -1,7 +1,7 @@ import { Model, model } from 'mongoose'; import { VoteSchema, voteSchema } from './vote.schema'; -voteSchema.index({ pollId: 1, userId: 1 }, { unique: true }); // Unique together +voteSchema.index({ pollId: 1, authorId: 1 }, { unique: true }); // Unique together export default model>('Vote', voteSchema); diff --git a/models/votes/vote.schema.ts b/models/votes/vote.schema.ts index 63ba212..d8128b3 100644 --- a/models/votes/vote.schema.ts +++ b/models/votes/vote.schema.ts @@ -1,12 +1,10 @@ import { Document, Schema, Types } from 'mongoose'; import { Vote } from 'which-types'; -export interface VoteSchema extends Document, Omit { - password: string; -} +export interface VoteSchema extends Document, Omit {}; export const voteSchema = new Schema({ - userId: { + authorId: { type: Types.ObjectId, ref: 'user', required: true -- cgit v1.2.3