* Add system_property.js

This commit is contained in:
Bryan Ashby 2015-10-17 20:56:16 -06:00
parent 9f11605c9b
commit d9ee2b6c80
1 changed files with 38 additions and 0 deletions

38
core/system_property.js Normal file
View File

@ -0,0 +1,38 @@
/* jslint node: true */
'use strict';
var sysDb = require('./database.js').dbs.system;
exports.loadSystemProperties = loadSystemProperties;
exports.persistSystemProperty = persistSystemProperty;
exports.getSystemProperty = getSystemProperty;
var systemProperties = {};
exports.systemProperties = systemProperties;
function loadSystemProperties(cb) {
sysDb.each(
'SELECT prop_name, prop_value ' +
'FROM system_property;',
function rowResult(err, row) {
systemProperties[row.prop_name] = row.prop_value;
},
cb
);
}
function persistSystemProperty(propName, propValue, cb) {
// update live
systemProperties[propName] = propValue;
sysDb.run(
'REPLACE INTO system_property ' +
'VALUES (?, ?);',
[ propName, propValue ],
cb
);
}
function getSystemProperty(propName) {
return systemProperties[propName];
}