MicroHack-Registrations-RestAPI / src / models / registration.model.ts
registration.model.ts
Raw
import { Model, Schema, model, Document } from 'mongoose';

export interface RegistrationD extends Document<RegistrationI>, RegistrationI {}

export interface RegistrationModelI extends Model<RegistrationD> {}

const RegistrationSchema: Schema = new Schema<RegistrationI>({
  firstName: { type: String, required: true },
  lastName: { type: String, required: true },
  email: { type: String, required: true },
  phone: { type: String, required: true },
  profession: { type: String, required: true , enum: ["Student", "Other"]},
  university: { type: String, default: 'N/A'},
  yearOfStudy: { type: String, enum: ['L1', 'L2', 'L3', 'M1', 'M2', 'N/A'], default: 'N/A' },
  nationalId: { type: String, default: 'N/A'},
  fieldOfStudy: { type: String, default: 'N/A'},
  skills:{
    type: [String],
    required: true,
    validate: {
      validator: (v: string[]) => v.length > 0,
      message: 'Skills are required'
    }
  },
  discordUsername: { type: String, default: 'N/A'},
  github: { type: String, default: 'N/A'},
  linkedin: { type: String , default: 'N/A'},
  portfolio: { type: String, default: 'N/A'},
  teamname: { type: String, default: 'N/A'},
  participatedQuest: { type: String, required: true },
  availableQuest: { type: String, required: true },
  fullDurationQuest: { type: String ,  default: 'N/A' },
  motivationQuest: { type: String, required: true },
  otherprofession : { type: String, default: 'N/A'},
});

export const RegistrationModel = model<RegistrationD, RegistrationModelI>(
  'Registration',
  RegistrationSchema
);

export default RegistrationModel;