2025-12-07 22:15:00 +00:00
|
|
|
const mongoose = require('mongoose');
|
|
|
|
|
|
|
|
|
|
const TagSchema = new mongoose.Schema({
|
|
|
|
|
name: {
|
|
|
|
|
type: String,
|
|
|
|
|
required: true,
|
|
|
|
|
unique: true,
|
|
|
|
|
lowercase: true,
|
|
|
|
|
trim: true,
|
|
|
|
|
maxlength: 50
|
|
|
|
|
},
|
|
|
|
|
category: {
|
|
|
|
|
type: String,
|
|
|
|
|
enum: ['theme', 'style', 'mood', 'technical'],
|
|
|
|
|
required: true
|
|
|
|
|
},
|
|
|
|
|
description: {
|
|
|
|
|
type: String,
|
|
|
|
|
maxlength: 200
|
|
|
|
|
},
|
|
|
|
|
// Количество использований (для популярности)
|
|
|
|
|
usageCount: {
|
|
|
|
|
type: Number,
|
|
|
|
|
default: 0
|
|
|
|
|
},
|
|
|
|
|
// Статус тега (approved, pending, rejected)
|
|
|
|
|
status: {
|
|
|
|
|
type: String,
|
|
|
|
|
enum: ['approved', 'pending', 'rejected'],
|
|
|
|
|
default: 'approved'
|
|
|
|
|
},
|
|
|
|
|
// Кто предложил тег (если был предложен пользователем)
|
|
|
|
|
suggestedBy: {
|
|
|
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
|
|
|
ref: 'User'
|
|
|
|
|
},
|
|
|
|
|
createdAt: {
|
|
|
|
|
type: Date,
|
|
|
|
|
default: Date.now
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Индексы для быстрого поиска
|
|
|
|
|
TagSchema.index({ name: 1 });
|
|
|
|
|
TagSchema.index({ category: 1 });
|
|
|
|
|
TagSchema.index({ status: 1 });
|
|
|
|
|
TagSchema.index({ usageCount: -1 });
|
|
|
|
|
|
|
|
|
|
module.exports = mongoose.model('Tag', TagSchema);
|
|
|
|
|
|
2025-12-08 20:11:50 +00:00
|
|
|
|