blob: 2f39aa19ae98d5e44a9ed7080e4ade29ba394a49 (
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
38
|
import { Document, Schema, Types } from 'mongoose';
export interface ImageDataSchema {
url: string;
votes: string[];
}
export interface PollSchema extends Document {
contents: {
left: ImageDataSchema;
right: ImageDataSchema;
};
createdAt: Date;
authorId: string;
vote: (userId: string, which: 'left' | 'right') => PollSchema;
}
export const imageDataSchema = {
url: String,
votes: [
{
type: Types.ObjectId,
ref: 'vote'
}
]
};
export const pollSchema = new Schema({
contents: {
left: imageDataSchema,
right: imageDataSchema
},
authorId: {
type: Types.ObjectId,
ref: 'User'
}
}, { timestamps: true });
|