Files
Checkmate/server/db/mongo/modules/settingsModule.js
T

31 lines
691 B
JavaScript
Raw Normal View History

2025-04-20 11:29:53 -07:00
import AppSettings from "../../models/AppSettings.js";
const SERVICE_NAME = "SettingsModule";
const getAppSettings = async () => {
try {
const settings = AppSettings.findOne();
return settings;
} catch (error) {
error.service = SERVICE_NAME;
error.method = "getSettings";
throw error;
}
};
const updateAppSettings = async (newSettings) => {
try {
2025-05-08 13:11:51 -07:00
console.log(newSettings);
2025-04-20 11:29:53 -07:00
const settings = await AppSettings.findOneAndUpdate(
{},
{ $set: newSettings },
2025-05-08 13:11:51 -07:00
{ new: true, upsert: true }
2025-04-20 11:29:53 -07:00
);
return settings;
} catch (error) {
error.service = SERVICE_NAME;
error.method = "updateAppSettings";
throw error;
}
};
export { getAppSettings, updateAppSettings };