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

31 lines
859 B
JavaScript

const { Schema, model } = require('mongoose')
const schema = new Schema({
startWashTime: {type: String, required: true},
endWashTime: {type: String, required: true},
orderDate: {type: String, required: true},
location: {type: String, required: true},
phone: {type: String, required: true},
status: {type: String, required: true},
carNumber: {type: String, required: true},
created: {
type: Date, default: () => new Date().toISOString(),
},
updated: {
type: Date, default: () => new Date().toISOString(),
},
master: {type: Schema.Types.ObjectId, ref: 'dry-wash-master'},
notes: String,
})
schema.set('toJSON', {
virtuals: true,
versionKey: false,
})
schema.virtual('id').get(function () {
return this._id.toHexString()
})
exports.OrderModel = model('dry-wash-order', schema)