diff --git a/src/models/ProfileSchema.ts b/src/models/ProfileSchema.ts new file mode 100644 index 0000000000000000000000000000000000000000..33291b490e9711c50e8161620ab335029b00161b --- /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 0000000000000000000000000000000000000000..8eec29a2ef19a109417338ebd7147f5a376094de --- /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}, + }} +});