All files / source/settings information.js

100% Statements 14/14
66.66% Branches 2/3
100% Functions 3/3
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32      3x 3x 2x       1x 1x 1x 2x   1x       1x 1x 1x 2x   1x                
import SettingsDao from '../../database/dao/settings';
 
async function getSettingCode(code) {
  const setting = await SettingsDao.findSetting({ code });
  if (setting) return setting.value;
  return null;
}
 
async function getSettingCodeList(codeList = []) {
  const settings = await SettingsDao.findAllSettings({ code: codeList });
  const data = {};
  for (const element of settings) {
    data[element.code] = element.value;
  }
  return data;
}
 
async function getAllSettings() {
  const settings = await SettingsDao.findAllSettings({});
  const data = {};
  for (const element of settings) {
    data[element.code] = element.value;
  }
  return data;
}
 
export default {
  getSettingCode,
  getSettingCodeList,
  getAllSettings,
};