summaryrefslogtreecommitdiff
path: root/src/models/EventGroup.ts
diff options
context:
space:
mode:
authorRaphael Kabo <raphaelkabo@hey.com>2023-10-06 12:32:37 +0100
committerRaphael Kabo <raphaelkabo@hey.com>2023-10-06 12:32:37 +0100
commit63cf813f4a284cfaec8114c623d13e9d650569f6 (patch)
tree655185cce75f8d6632f8761e62c64bd53be71da9 /src/models/EventGroup.ts
parent6e5e2e5fc55f5ff1c78c41d0acbdcf82221fc2cf (diff)
Add Typescript interfaces for Mongoose models
Diffstat (limited to 'src/models/EventGroup.ts')
-rwxr-xr-xsrc/models/EventGroup.ts75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/models/EventGroup.ts b/src/models/EventGroup.ts
new file mode 100755
index 0000000..f097843
--- /dev/null
+++ b/src/models/EventGroup.ts
@@ -0,0 +1,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);