multy-stub/server/routers/dry-wash/model/order.js

63 lines
1.2 KiB
JavaScript
Raw Normal View History

2024-12-15 17:53:45 +03:00
const { Schema, model } = require('mongoose')
2025-01-18 23:02:45 +03:00
const { orderStatus } = require('./const')
2024-12-15 17:53:45 +03:00
const schema = new Schema({
2025-01-18 23:02:45 +03:00
phone: {
type: String,
required: true
},
carNumber: {
type: String,
required: true
},
carBody: {
type: Number,
required: true
},
carColor: String,
startWashTime: {
type: Date,
required: true
},
endWashTime: {
type: Date,
required: true
},
location: {
type: String,
required: true
},
status: {
type: String,
required: true,
enum: Object.values(orderStatus)
},
master: {
type: Schema.Types.ObjectId,
ref: 'dry-wash-master'
},
notes: String,
2024-12-15 17:53:45 +03:00
created: {
2025-01-18 23:02:45 +03:00
type: Date,
default: () => new Date().toISOString(),
2024-12-15 17:53:45 +03:00
},
updated: {
2025-01-18 23:02:45 +03:00
type: Date,
default: () => new Date().toISOString(),
2024-12-15 17:53:45 +03:00
},
})
schema.set('toJSON', {
virtuals: true,
versionKey: false,
2025-01-18 23:02:45 +03:00
transform(_doc, ret) {
delete ret._id
}
2024-12-15 17:53:45 +03:00
})
schema.virtual('id').get(function () {
return this._id.toHexString()
})
exports.OrderModel = model('dry-wash-order', schema)