import { Schema, model, Document } from "mongoose"; import type { Report as ReportType, Fault as FaultType } from "../formHandler"; interface ReportDocument extends ReportType, Document {} const FaultSchema = new Schema({ coach: { type: String, required: true }, zone: { type: String, required: true }, }, { _id: false }); // Prevents Mongoose from auto-generating _id for each fault const ReportSchema = new Schema({ unitNumber: { type: String, required: true }, reported: { type: String, required: true }, comments: { type: String, required: false }, utcTimestamp: { type: Date, required: true }, faults: { type: [FaultSchema], required: true }, }); export const Report = model('Report', ReportSchema);