From 50f7bd91e280a374a7c5f58f0462a07eb821f41c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bodor=20M=C3=A1t=C3=A9?= <bmate711@gmail.com>
Date: Fri, 1 May 2020 18:12:59 +0200
Subject: [PATCH] Create profile and warning schema/interface

---
 src/models/ProfileSchema.ts | 24 ++++++++++++++++++++++++
 src/models/WarningSchema.ts | 19 +++++++++++++++++++
 2 files changed, 43 insertions(+)
 create mode 100644 src/models/ProfileSchema.ts
 create mode 100644 src/models/WarningSchema.ts

diff --git a/src/models/ProfileSchema.ts b/src/models/ProfileSchema.ts
new file mode 100644
index 00000000..33291b49
--- /dev/null
+++ b/src/models/ProfileSchema.ts
@@ -0,0 +1,24 @@
+import { Document, Schema, model } from 'mongoose';
+import { IWarnings, WarningSchema } from './WarningSchema';
+
+export interface IProfile extends Document {
+    external_id: string,
+    studentCardNumber: string,
+    roomNumber?: string,
+    picture: any,
+    role: string,
+    email?: string,
+    name?: string,
+    warnings: [IWarnings] | [],
+};
+
+const ProfileSchema = new Schema({
+    external_id: {type: String, required: true },
+    studentCardNumber: {type: String, required: true },
+    roomNumber: {type: String},
+    picture: {type: String},
+    role: {type: String, required: true},
+    warnings: [WarningSchema]
+});
+
+export default model<IProfile>('News', ProfileSchema);
\ No newline at end of file
diff --git a/src/models/WarningSchema.ts b/src/models/WarningSchema.ts
new file mode 100644
index 00000000..8eec29a2
--- /dev/null
+++ b/src/models/WarningSchema.ts
@@ -0,0 +1,19 @@
+import { Schema } from 'mongoose';
+
+export interface IWarnings extends Document{
+    text: string,
+    date: Date,
+    given_by: {
+        _id: string,
+        name: string,
+    } 
+}
+
+export const WarningSchema = new Schema({
+    text: {type: String, required: true},
+    date: {type: Date, required: true},
+    given_by: {required: true, type: {
+        _id: {type: String, required: true},
+        name: {String, required: true},
+    }}
+});
-- 
GitLab