| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- import mongoose from "mongoose";
- const customInputSchema = new mongoose.Schema({
- name: {
- type: String,
- required: true
- },
- type: {
- type: String,
- enum: ["tel", "text", "email"],
- requried: true
- }
- },
- {_id: false});
- const customTimesSchema = new mongoose.Schema({
- date: {
- type: Date,
- required: true
- },
- available: {
- type: Boolean,
- default: false
- }
- },
- {_id: false});
- /**
- * Define a schema for an appointment using mongoose.
- *
- * @description This schema represents an appointment between a user and a service provider.
- * @typedef {Object} AppointmentSchema
- * @property {String} user - The ID of the user making the appointment (e.g. "user123").
- * @property {String} title - A brief title for the appointment (e.g. " haircut").
- * @property {String} description - A longer description of the appointment.
- * @property {Date} dueDate - The date and time when the appointment is scheduled.
- * @property {String} place - The location where the appointment will take place.
- */
- /**
- * Create a mongoose model for appointments using the defined schema.
- *
- * @description This model allows you to interact with the appointments collection in your MongoDB database.
- * @typedef {Object} Appointment
- * @static
- */
- const appointmentSchema = new mongoose.Schema({
- user: {
- type: String,
- required: true
- },
- title: {
- type: String,
- required: true
- },
- description: {
- type: String
- },
- dueDate: {
- type: Date,
- required: true
- },
- place: {
- type: String
- },
- duration: {
- type: Number,
- required: true
- },
- times: [customTimesSchema],
- inputs: [customInputSchema]
- });
- /**
- * Create a mongoose model for appointments and name it "Appointment".
- *
- * @description This model allows you to interact with the appointments collection in your MongoDB database.
- */
- const Appointment = mongoose.model('Appointment', appointmentSchema, 'appointment');
- export default Appointment;
|