import mongoose, { Document, Schema } from 'mongoose';

export interface IGeometryType extends Document {
    name: string;
    efficiencyLoss: number; // Percentage, e.g., 10 for 10%
    organizationId: string;
    createdAt: Date;
    updatedAt: Date;
}

const GeometryTypeSchema: Schema = new Schema({
    name: { type: String, required: true },
    efficiencyLoss: { type: Number, required: true, default: 0 },
    organizationId: { type: String, required: true, index: true },
}, {
    timestamps: true
});

// Compound index to ensure unique names per organization
GeometryTypeSchema.index({ organizationId: 1, name: 1 }, { unique: true });

export default mongoose.model<IGeometryType>('GeometryType', GeometryTypeSchema);
