import mongoose from 'mongoose'

const tagSchema = new mongoose.Schema({
  slug: { type: String, required: true, unique: true },
  label: { type: String, required: true },
  pool: { type: String, enum: ['craft', 'cooperative'], required: true },
  active: { type: Boolean, default: true },
  createdAt: { type: Date, default: Date.now },
})

tagSchema.index({ pool: 1, active: 1 })

export default mongoose.models.Tag || mongoose.model('Tag', tagSchema)
