harris_paint / src /models /SystemConfig.js
aliroohan179's picture
Upload 58 files
10821c7 verified
Raw
History Blame Contribute Delete
784 Bytes
const mongoose = require('mongoose');
const systemConfigSchema = new mongoose.Schema(
{
paintCalculator: {
windowDeduction: { type: Number, default: 1.5 },
doorDeduction: { type: Number, default: 2.0 },
defaultCoats: { type: Number, default: 2 },
},
admin: {
passwordMinLength: { type: Number, default: 12 },
passwordExpiryDays: { type: Number, default: 90 },
bcryptSaltRounds: { type: Number, default: 12 },
},
},
{ timestamps: true }
);
// Ensure only one config document exists
systemConfigSchema.statics.getConfig = async function () {
let config = await this.findOne();
if (!config) {
config = await this.create({});
}
return config;
};
module.exports = mongoose.model('SystemConfig', systemConfigSchema);