Some checks are pending
Server Tests / Mocha – Unit & Utility Tests (push) Waiting to run
33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
const mongoose = require('mongoose'),
|
|
Schema = mongoose.Schema;
|
|
|
|
const dealerSchema = new Schema({
|
|
companyName: { type: String, required: true, trim: true },
|
|
country: { type: String, required: true, trim: true },
|
|
contactName: { type: String, trim: true, default: '' },
|
|
address: { type: String, trim: true, default: '' },
|
|
phone: { type: String, trim: true, default: '' },
|
|
cell: { type: String, trim: true, default: '' },
|
|
fax: { type: String, trim: true, default: '' },
|
|
email: { type: String, trim: true, lowercase: true, default: '' },
|
|
website: { type: String, trim: true, default: '' },
|
|
isCertifiedRepair: { type: Boolean, default: false },
|
|
notes: { type: String, trim: true, default: '' },
|
|
createdAt: { type: Date, default: Date.now },
|
|
updatedAt: { type: Date, default: Date.now }
|
|
}, { strictQuery: false });
|
|
|
|
dealerSchema.pre('save', function (next) {
|
|
this.updatedAt = new Date();
|
|
next();
|
|
});
|
|
|
|
dealerSchema.pre('findOneAndUpdate', function (next) {
|
|
this.set({ updatedAt: new Date() });
|
|
next();
|
|
});
|
|
|
|
module.exports = mongoose.model('Dealer', dealerSchema);
|