I have an Expressjs application running on NodeJS 0.8.8 using MongoDB and the Jade template language, and I would like to allow the user to configure many presentation parameters on the site, such as page names, logo, etc.
How to save these configuration parameters in the mongoDB database so that I can read them when the application starts, manage them while the application is running and display them in jade templates?
Here is my general application setup:
var app = module.exports = express();
global.app = app;
var DB = require('./accessDB');
var conn = 'mongodb://localhost/dbname';
var db;
app.configure(function(){
...
});
db = new DB.startup(conn);
app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
app.locals.moment = moment;
require('./routes')(app);
So far I have created a model called "Site" for the "siteConfig" collection, and I have a getSiteConfig function in accessDB.js that runs Site.find () ... to get the fields in one document in the Collection.
, : -, ? , moment.js? :
db.getSiteConfig(function(err, siteConfig){
if (err) {throw err;}
app.locals.siteConfig = siteConfig;
});
, ?
!