Skip to content
Snippets Groups Projects
ProfileSchema.ts 836 B
import { Document, Schema, model } from 'mongoose';
import { IWarnings, WarningSchema } from './WarningSchema';
import { Admin } from 'mongodb';

export enum Role {
    Admin,
    Staff,
    User,
}

export interface IProfile extends Document {
    external_id: string,
    studentCardNumber: string,
    roomNumber?: string,
    picture: string,
    role: Role.Admin | Role.Staff | Role.User,
    email?: string,
    name?: string,
    warnings: [IWarnings] | [],
};

const ProfileSchema = new Schema({
    external_id: {type: String, required: true, unique : true, dropDups: true },
    studentCardNumber: {type: String, required: true },
    roomNumber: {type: String},
    picture: {type: String},
    role: {type: String, required: true},
    warnings: [WarningSchema]
});

export default model<IProfile>('Profile', ProfileSchema);