summaryrefslogtreecommitdiff
path: root/src/models/EventGroup.ts
blob: f097843c26fadf9fc7735ab2fb241c9d770c760a (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import mongoose from "mongoose";

export interface ISubscriber {
  email?: string;
}

export interface IEventGroup extends mongoose.Document {
  id: string;
  name: string;
  description: string;
  image?: string;
  url?: string;
  creatorEmail?: string;
  hostName?: string;
  editToken?: string;
  firstLoad?: boolean;
  events?: mongoose.Types.ObjectId[];
  subscribers?: ISubscriber[];
}

const Subscriber = new mongoose.Schema({
  email: {
    type: String,
    trim: true,
  },
});

const EventGroupSchema = new mongoose.Schema({
  id: {
    type: String,
    required: true,
    unique: true,
  },
  name: {
    type: String,
    trim: true,
    required: true,
  },
  description: {
    type: String,
    trim: true,
    required: true,
  },
  image: {
    type: String,
    trim: true,
  },
  url: {
    type: String,
    trim: true,
  },
  creatorEmail: {
    type: String,
    trim: true,
  },
  hostName: {
    type: String,
    trim: true,
  },
  editToken: {
    type: String,
    trim: true,
    minlength: 32,
    maxlength: 32,
  },
  firstLoad: {
    type: Boolean,
    trim: true,
    default: true,
  },
  events: [{ type: mongoose.Schema.Types.ObjectId, ref: "Event" }],
  subscribers: [Subscriber],
});

export default mongoose.model<IEventGroup>("EventGroup", EventGroupSchema);