appointmentSchema.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import mongoose from "mongoose";
  2. /**
  3. * Define a schema for an appointment using mongoose.
  4. *
  5. * @description This schema represents an appointment between a user and a service provider.
  6. * @typedef {Object} AppointmentSchema
  7. * @property {String} user - The ID of the user making the appointment (e.g. "user123").
  8. * @property {String} title - A brief title for the appointment (e.g. " haircut").
  9. * @property {String} description - A longer description of the appointment.
  10. * @property {Date} dueDate - The date and time when the appointment is scheduled.
  11. * @property {String} place - The location where the appointment will take place.
  12. * @property {Date} startDate - The start date and time of the appointment.
  13. * @property {Date} endDate - The end date and time of the appointment.
  14. */
  15. /**
  16. * Create a mongoose model for appointments using the defined schema.
  17. *
  18. * @description This model allows you to interact with the appointments collection in your MongoDB database.
  19. * @typedef {Object} Appointment
  20. * @static
  21. */
  22. const appointmentSchema = new mongoose.Schema({
  23. user: {
  24. type: String,
  25. required: true
  26. },
  27. title: {
  28. type: String,
  29. required: true
  30. },
  31. description: {
  32. type: String,
  33. required: true
  34. },
  35. dueDate: {
  36. type: Date,
  37. required: true
  38. },
  39. place: {
  40. type: String,
  41. required: true
  42. },
  43. startDate: {
  44. type: Date,
  45. required: true
  46. },
  47. endDate: {
  48. type: Date,
  49. required: true
  50. }
  51. });
  52. /**
  53. * Create a mongoose model for appointments and name it "Appointment".
  54. *
  55. * @description This model allows you to interact with the appointments collection in your MongoDB database.
  56. */
  57. const Appointment = mongoose.model('Appointment', appointmentSchema, 'appointment');
  58. export default Appointment;