19 lines
765 B
TypeScript
19 lines
765 B
TypeScript
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<FaultType>({
|
|
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<ReportDocument>({
|
|
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<ReportDocument>('Report', ReportSchema); |