Connected to MongoDB
Error during referral submission: Error: Referral validation failed: relationship: Path `relationship` is required.
    at ValidationError.inspect (C:\Users\Administrator\Downloads\employee-referral-portal\backend\node_modules\mongoose\lib\error\validation.js:52:26)
    at formatValue (node:internal/util/inspect:806:19)
    at inspect (node:internal/util/inspect:365:10)
    at formatWithOptionsInternal (node:internal/util/inspect:2304:40)
    at formatWithOptions (node:internal/util/inspect:2166:10)
    at console.value (node:internal/console/constructor:357:14)
    at console.error (node:internal/console/constructor:394:61)
    at sendReferral (C:\Users\Administrator\Downloads\employee-referral-portal\backend\controllers\referralController.js:69:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  errors: {
    relationship: ValidatorError: Path `relationship` is required.
        at validate (C:\Users\Administrator\Downloads\employee-referral-portal\backend\node_modules\mongoose\lib\schemaType.js:1404:13)
        at SchemaType.doValidate (C:\Users\Administrator\Downloads\employee-referral-portal\backend\node_modules\mongoose\lib\schemaType.js:1388:7)
        at C:\Users\Administrator\Downloads\employee-referral-portal\backend\node_modules\mongoose\lib\document.js:3104:18
        at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {
      properties: [Object],
      kind: 'required',
      path: 'relationship',
      value: undefined,
      reason: undefined,
      [Symbol(mongoose#validatorError)]: true
    }
  },
  _message: 'Referral validation failed'
}
Error during referral submission: Error: Referral validation failed: relationship: Path `relationship` is required.
    at ValidationError.inspect (C:\Users\Administrator\Downloads\employee-referral-portal\backend\node_modules\mongoose\lib\error\validation.js:52:26)
    at formatValue (node:internal/util/inspect:806:19)
    at inspect (node:internal/util/inspect:365:10)
    at formatWithOptionsInternal (node:internal/util/inspect:2304:40)
    at formatWithOptions (node:internal/util/inspect:2166:10)
    at console.value (node:internal/console/constructor:357:14)
    at console.error (node:internal/console/constructor:394:61)
    at sendReferral (C:\Users\Administrator\Downloads\employee-referral-portal\backend\controllers\referralController.js:69:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  errors: {
    relationship: ValidatorError: Path `relationship` is required.
        at validate (C:\Users\Administrator\Downloads\employee-referral-portal\backend\node_modules\mongoose\lib\schemaType.js:1404:13)
        at SchemaType.doValidate (C:\Users\Administrator\Downloads\employee-referral-portal\backend\node_modules\mongoose\lib\schemaType.js:1388:7)
        at C:\Users\Administrator\Downloads\employee-referral-portal\backend\node_modules\mongoose\lib\document.js:3104:18
        at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {
      properties: [Object],
      kind: 'required',
      path: 'relationship',
      value: undefined,
      reason: undefined,
      [Symbol(mongoose#validatorError)]: true
    }
  },
  _message: 'Referral validation failed'
}
   this error const mongoose = require('mongoose');

const referralSchema = new mongoose.Schema({
  candidateName: { type: String, required: true },
  email: { type: String, required: true },
  mobile: { type: String, required: true },
  experience: { type: String, required: true },
  applyingFor: { type: String, required: true },
  relationship: { type: String, required: true },
  
  resume: { type: String },
  referredBy: {
    name: { type: String, required: true },
    email: { type: String, required: true }
  },
  createdAt: { type: Date, default: Date.now }
});

module.exports = mongoose.model('Referral', referralSchema);