diff options
Diffstat (limited to 'models')
-rw-r--r-- | models/polls/poll.schema.ts | 9 | ||||
-rw-r--r-- | models/users/user.schema.ts | 4 |
2 files changed, 10 insertions, 3 deletions
diff --git a/models/polls/poll.schema.ts b/models/polls/poll.schema.ts index 79036c3..ea91051 100644 --- a/models/polls/poll.schema.ts +++ b/models/polls/poll.schema.ts @@ -1,18 +1,23 @@ import { Document, Schema, Types } from 'mongoose'; +import { User } from '../users/user.schema' interface ImageData { url: string; votes: number; } -export interface PollSchema 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, diff --git a/models/users/user.schema.ts b/models/users/user.schema.ts index 5292add..e39f667 100644 --- a/models/users/user.schema.ts +++ b/models/users/user.schema.ts @@ -1,11 +1,13 @@ import { Document, Schema } from "mongoose" -export interface UserSchema extends Document { +export interface User { name: string; avatarUrl?: string; age?: number; } +export interface UserSchema extends Document, User {} + export const userSchema = new Schema({ name: String, avatarUrl: { |