From de9771959850f193f173616b73099c3ae6f010c9 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Tue, 9 Jun 2020 19:23:44 +0300 Subject: feat!: integrate mongoDB --- models/polls/poll.schema.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 models/polls/poll.schema.ts (limited to 'models/polls/poll.schema.ts') diff --git a/models/polls/poll.schema.ts b/models/polls/poll.schema.ts new file mode 100644 index 0000000..2e7dccd --- /dev/null +++ b/models/polls/poll.schema.ts @@ -0,0 +1,33 @@ +import { Document, Schema, Types } from 'mongoose'; +import { User } from '../users/user.schema'; + +interface ImageData { + url: string; + votes: number; +} + +export interface Poll extends Document { + authorId: string; + contents: { + left: ImageData; + right: ImageData; + }; +} + + +const imageDataSchema = { + url: String, + votes: Number +} + +export const PollSchema = new Schema({ + contents: { + left: imageDataSchema, + right: imageDataSchema + }, + authorId: { + type: Types.ObjectId, + ref: 'User' + } +}); + -- cgit v1.2.3