обновил бэк закупок
This commit is contained in:
46
server/routers/procurement/models/Product.js
Normal file
46
server/routers/procurement/models/Product.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const mongoose = require('mongoose')
|
||||
|
||||
const productSchema = new mongoose.Schema({
|
||||
name: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
category: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
required: true,
|
||||
minlength: 20,
|
||||
maxlength: 500
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
enum: ['sell', 'buy'],
|
||||
required: true
|
||||
},
|
||||
productUrl: String,
|
||||
companyId: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: 'Company',
|
||||
required: true
|
||||
},
|
||||
price: String,
|
||||
unit: String,
|
||||
minOrder: String,
|
||||
createdAt: {
|
||||
type: Date,
|
||||
default: Date.now
|
||||
},
|
||||
updatedAt: {
|
||||
type: Date,
|
||||
default: Date.now
|
||||
}
|
||||
})
|
||||
|
||||
// Индекс для поиска
|
||||
productSchema.index({ companyId: 1, type: 1 })
|
||||
productSchema.index({ name: 'text', description: 'text' })
|
||||
|
||||
module.exports = mongoose.model('Product', productSchema)
|
||||
Reference in New Issue
Block a user