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);