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 buyProductSchema = new mongoose.Schema({
companyId: {
type: String,
required: true,
index: true
},
name: {
type: String,
required: true
},
description: {
type: String,
required: true,
minlength: 10,
maxlength: 1000
},
quantity: {
type: String,
required: true
},
unit: {
type: String,
default: 'шт'
},
files: [{
id: String,
name: String,
url: String,
type: String,
size: Number,
uploadedAt: {
type: Date,
default: Date.now
}
}],
status: {
type: String,
enum: ['draft', 'published'],
default: 'published'
},
createdAt: {
type: Date,
default: Date.now,
index: true
},
updatedAt: {
type: Date,
default: Date.now
}
});
// Индексы для оптимизации поиска
buyProductSchema.index({ companyId: 1, createdAt: -1 });
buyProductSchema.index({ name: 'text', description: 'text' });
module.exports = mongoose.model('BuyProduct', buyProductSchema);