Creation of appointments Collection (RF02)` #85

Closed
opened 2025-10-31 00:59:55 +00:00 by GFMpt13 · 1 comment
GFMpt13 commented 2025-10-31 00:59:55 +00:00 (Migrated from github.com)

This task involves designing a new collection, appointments, to manage service bookings and the workshop's agenda. This directly supports the functional requirement RF02 ("Gerir marcações e agenda de serviços").

This collection will link a client to a specific date and time, and optionally link to a vehicle and/a work order if they already exist.

Tasks

  • 1. Define Schema:

    • clientId (Type: ObjectId, Required, Ref: clients): The client making the appointment.
    • appointmentDate (Type: ISODate, Required): The date and time of the scheduled booking.
    • vehicleId (Type: ObjectId, Optional, Ref: vehicles): The specific vehicle for the appointment.
    • workOrderId (Type: ObjectId, Optional, Ref: workOrders): Links the appointment to an existing work order (e.g., for a follow-up or check-up).
    • notes (Type: String, Optional): Client-provided notes or the service to be performed (e.g., "Check brakes," "Annual service," "Client reports noise").
    • status (Type: String, Required): Enum: Scheduled, Completed, Canceled. Manages the appointment lifecycle.
    • createdAt (Type: ISODate, Required): Standard document creation timestamp.
    • updatedAt (Type: ISODate, Required): Standard document update timestamp.
  • 2. Define Schema Validation:

    • Create the JSON schema validator, ensuring clientId, appointmentDate, and status are required.
  • 3. Define Indexes:

    • db.appointments.createIndex({ appointmentDate: -1 }) (To quickly query the agenda, newest first).
    • db.appointments.createIndex({ clientId: 1 }) (To quickly find all appointments for a specific client).
    • db.appointments.createIndex({ status: 1, appointmentDate: 1 }) (Compound index to find appointments by status, sorted by date, e.g., "all 'Scheduled' appointments for the week").
  • 4. Update Documentation

    • Update DB architecture documentation
    • Update DB setup script
  • 5. Update Database with the new collection

This task involves designing a new collection, `appointments`, to manage service bookings and the workshop's agenda. This directly supports the functional requirement **RF02 ("Gerir marcações e agenda de serviços")**. This collection will link a client to a specific date and time, and optionally link to a vehicle and/a work order if they already exist. ### Tasks - [x] 1. **Define Schema:** - [x] `clientId` (Type: `ObjectId`, Required, Ref: `clients`): The client making the appointment. - [x] `appointmentDate` (Type: `ISODate`, Required): The date and time of the scheduled booking. - [x] `vehicleId` (Type: `ObjectId`, Optional, Ref: `vehicles`): The specific vehicle for the appointment. - [x] `workOrderId` (Type: `ObjectId`, Optional, Ref: `workOrders`): Links the appointment to an existing work order (e.g., for a follow-up or check-up). - [x] `notes` (Type: `String`, Optional): Client-provided notes or the service to be performed (e.g., "Check brakes," "Annual service," "Client reports noise"). - [x] `status` (Type: `String`, Required): Enum: `Scheduled`, `Completed`, `Canceled`. Manages the appointment lifecycle. - [x] `createdAt` (Type: `ISODate`, Required): Standard document creation timestamp. - [x] `updatedAt` (Type: `ISODate`, Required): Standard document update timestamp. - [x] 2. **Define Schema Validation:** - [x] Create the JSON schema validator, ensuring `clientId`, `appointmentDate`, and `status` are required. - [x] 3. **Define Indexes:** - [x] `db.appointments.createIndex({ appointmentDate: -1 })` (To quickly query the agenda, newest first). - [x] `db.appointments.createIndex({ clientId: 1 })` (To quickly find all appointments for a specific client). - [x] `db.appointments.createIndex({ status: 1, appointmentDate: 1 })` (Compound index to find appointments by status, sorted by date, e.g., "all 'Scheduled' appointments for the week"). - [x] 4. **Update Documentation** - [x] Update DB architecture documentation - [x] Update DB setup script - [x] 5. **Update Database with the new collection**
GFMpt13 commented 2025-10-31 01:07:53 +00:00 (Migrated from github.com)

appointments collection desing:

Image
appointments collection desing: <img width="379" height="270" alt="Image" src="https://github.com/user-attachments/assets/e13669fb-7b08-4847-9424-e001bc721a67" />
Sign in to join this conversation.
No description provided.