nodejs中的对象可以当作hash表来用吗
1个回答
展开全部
var config = new Map();
// mysql
config.set('mysql', {
host: '127.0.0.1',
port: 3306,
user: '', // enter username
password: '', // input password
database: '' // input database
});
// redis
config.set('redis', {
host: '127.0.0.1',
port: 6379
});
// email
// tips: don't use qq mail
config.set('email', {
service: '126',
username: 'xxxx@126.com',
password: 'xxxxx'
});
// merge config from local.js
// if local.js is existed and local.js defines the configuration is used to local's, otherwise use global's
// like array_merge function in php
var fs = require('fs');
if (fs.existsSync(__dirname + '/local.js')) {
var customer = require('./local');
customer.forEach(function (value, key) {
config.set(key, value);
});
}
module.exports = config;
// mysql
config.set('mysql', {
host: '127.0.0.1',
port: 3306,
user: '', // enter username
password: '', // input password
database: '' // input database
});
// redis
config.set('redis', {
host: '127.0.0.1',
port: 6379
});
// tips: don't use qq mail
config.set('email', {
service: '126',
username: 'xxxx@126.com',
password: 'xxxxx'
});
// merge config from local.js
// if local.js is existed and local.js defines the configuration is used to local's, otherwise use global's
// like array_merge function in php
var fs = require('fs');
if (fs.existsSync(__dirname + '/local.js')) {
var customer = require('./local');
customer.forEach(function (value, key) {
config.set(key, value);
});
}
module.exports = config;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询