blob: ea91051954cbf18fb6bb98f95750decd2cb0cd5d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
import { Document, Schema, Types } from 'mongoose';
import { User } from '../users/user.schema'
interface ImageData {
url: string;
votes: number;
}
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({
contents: {
left: imageDataSchema,
right: imageDataSchema
},
authorId: {
type: Types.ObjectId,
ref: 'User'
}
});
|