Question

I'm trying to use Compound JS and want to load on startup some values from DB and store them in global variables shared across all sessions.

How can I do it?

Was it helpful?

Solution

One way would be to put them in the config/initializers folder.

Example: /config/initializers/settings.js

module.exports = function (compound) {
    compound.models.Setting.all(function (err, settings) {
        compound.settings = settings;
    });
};
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top