agmission/Development/server/model/setting.js

43 lines
1.2 KiB
JavaScript

const { DEFAULT_TRIAL_DAYS } = require('../helpers/constants');
const mongoose = require('mongoose'),
Schema = mongoose.Schema;
const schema = new Schema({
userId: { type: Schema.Types.ObjectId, ref: 'User' },
// Global measureUnit, whether isUS measurement unit
measureUnit: { type: Boolean, default: false },
jobsByPilot: { type: Boolean, default: false },
matType: { type: Number, default: 0 }, // 0: Liquid, 1: Dry
// Spray Path options for spray lines drawing or making Application reports
sprayPath: {
overlap: { type: Number, min: 10, max: 200, default: 120 }, // Percentage: 10 - 200
dataOp: { type: Number, default: 0 }
},
upload: {
updateOp: String
},
colors: { type: Schema.Types.Mixed },
obstacles: { type: Schema.Types.Mixed },
mapOps: { type: Schema.Types.Mixed },
track: { type: Schema.Types.Mixed },
noPopup: { type: Boolean, default: false },
// Nunber of trial days for Agmission's applicators
trialDays: { type: [Number] },
testing: { type: Schema.Types.Mixed }
});
schema.post('save', function (next) {
if (!this.trialDays || this.trialDays.length)
this.trialDays = DEFAULT_TRIAL_DAYS;
next();
});
module.exports = mongoose.model('Setting', schema);