Zugriff auf Konfigurationsvariablen aus anderen Konfigurationsdateien
Ich habe Probleme, eine Konfigurationsvariable in einer anderen Konfigurationsdatei zu verwenden. Z.B
// file - config/local.js
module.exports = {
mongo_db : {
username : 'TheUsername',
password : 'ThePassword',
database : 'TheDatabase'
}
}
// file - config/connections.js
module.exports.connections = {
mongo_db: {
adapter: 'sails-mongo',
host: 'localhost',
port: 27017,
user: sails.config.mongo_db.username,
password: sails.config.mongo_db.password,
database: sails.config.mongo_db.database
},
}
Wenn ich 'Segel hebe', erhalte ich den folgenden Fehler:
user: sails.config.mongo_db.username,
^
ReferenceError: sails is not defined
Ich kann an anderen Stellen auf die Konfigurationsvariablen zugreifen - z. B. funktioniert dies wie folgt:
// file - config/bootstrap.js
module.exports.bootstrap = function(cb) {
console.log('Dumping config: ', sails.config);
cb();
}
Dies speichert alle Konfigurationseinstellungen in der Konsole - ich kann sogar die Konfigurationseinstellungen für mongo_db dort sehen!
ch bin so verwirr