new procurement

This commit is contained in:
2025-10-23 09:49:04 +03:00
parent 99127c42e2
commit a6065dd95c
22 changed files with 1588 additions and 409 deletions

View File

@@ -0,0 +1,58 @@
const mongoose = require('mongoose');
const reviewSchema = new mongoose.Schema({
companyId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Company',
required: true,
index: true
},
authorCompanyId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Company',
required: true
},
authorName: {
type: String,
required: true
},
authorCompany: {
type: String,
required: true
},
rating: {
type: Number,
required: true,
min: 1,
max: 5
},
comment: {
type: String,
required: true,
minlength: 10,
maxlength: 1000
},
date: {
type: Date,
default: Date.now
},
verified: {
type: Boolean,
default: true
},
createdAt: {
type: Date,
default: Date.now,
index: true
},
updatedAt: {
type: Date,
default: Date.now
}
});
// Индексы для оптимизации поиска
reviewSchema.index({ companyId: 1, createdAt: -1 });
reviewSchema.index({ authorCompanyId: 1 });
module.exports = mongoose.model('Review', reviewSchema);