diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-06-11 01:15:01 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-11 01:15:01 +0300 |
commit | 40b804ffdd26a0c9bab95b4ec6a539d9fe429ed3 (patch) | |
tree | 7cdb3cb7b86e3333c15bbaefe14fe228cc93d023 /models/polls | |
parent | de9771959850f193f173616b73099c3ae6f010c9 (diff) | |
parent | d40f6e6cf8150f9e112d0b5d8d7075c2fc90264b (diff) | |
download | which-api-40b804ffdd26a0c9bab95b4ec6a539d9fe429ed3.tar.gz |
Merge pull request #3 from eug-vs/hooks
Expand authorId field in polls
Diffstat (limited to 'models/polls')
-rw-r--r-- | models/polls/poll.model.ts | 4 | ||||
-rw-r--r-- | models/polls/poll.schema.ts | 12 |
2 files changed, 10 insertions, 6 deletions
diff --git a/models/polls/poll.model.ts b/models/polls/poll.model.ts index 211d1e6..be1f604 100644 --- a/models/polls/poll.model.ts +++ b/models/polls/poll.model.ts @@ -1,5 +1,5 @@ import { Model, model } from "mongoose" -import { Poll, PollSchema } from './poll.schema'; +import { PollSchema, pollSchema } from './poll.schema'; -export default model<Poll, Model<Poll>>("Poll", PollSchema); +export default model<PollSchema, Model<PollSchema>>("Poll", pollSchema); diff --git a/models/polls/poll.schema.ts b/models/polls/poll.schema.ts index 2e7dccd..ea91051 100644 --- a/models/polls/poll.schema.ts +++ b/models/polls/poll.schema.ts @@ -1,26 +1,30 @@ import { Document, Schema, Types } from 'mongoose'; -import { User } from '../users/user.schema'; +import { User } from '../users/user.schema' interface ImageData { url: string; votes: number; } -export interface Poll extends Document { - authorId: string; +export interface Poll { + author: User; contents: { left: ImageData; right: ImageData; }; } +export interface PollSchema extends Document, Omit<Poll, 'author'> { + authorId: string; +} + const imageDataSchema = { url: String, votes: Number } -export const PollSchema = new Schema({ +export const pollSchema = new Schema({ contents: { left: imageDataSchema, right: imageDataSchema |