const mongoose = require('mongoose') const ObjectID = mongoose.Schema.Types.ObjectId const featureSchema = new mongoose.Schema({ nativeName: { type: String, required: true, }, englishName: { type: String, required: true, }, category: { type: ObjectID, ref: 'Category', required: true, }, predefinedValues: [String], unit: String, isFilterable: { type: Boolean, default: true, }, featureType: { type: String, enum: ['string', 'boolean', 'number', 'date'], default: 'string', }, filterType: { type: String, enum: ['exact', 'range', 'multi', 'bool'], default: 'exact', }, tag: String, priority: Number, }, { toJSON: { virtuals: true }, toObject: { virtuals: true }, timestamps: true, }) featureSchema.index({ englishName: 1, category: 1 }, { unique: true }) const Feature = mongoose.model('Feature', featureSchema) module.exports = Feature