Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用 Compound JS,并希望在启动时从 DB 加载一些值并将它们存储在所有会话共享的全局变量中。
我该怎么做?
一种方法是将它们放在config/initializers文件夹中。
config/initializers
例子:/config/initializers/settings.js
/config/initializers/settings.js
module.exports = function (compound) { compound.models.Setting.all(function (err, settings) { compound.settings = settings; }); };