const mongoose = require("mongoose"); const ReportSchema = new mongoose.Schema( { street: { type: mongoose.Schema.Types.ObjectId, ref: "Street", required: true, }, user: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: true, }, issue: { type: String, required: true, }, imageUrl: { type: String, }, cloudinaryPublicId: { type: String, }, status: { type: String, enum: ["open", "resolved"], default: "open", }, }, { timestamps: true, }, ); // Indexes for performance ReportSchema.index({ street: 1, status: 1 }); ReportSchema.index({ user: 1 }); ReportSchema.index({ createdAt: -1 }); module.exports = mongoose.model("Report", ReportSchema);