正在显示
1 个修改的文件
包含
12 行增加
和
6 行删除
... | ... | @@ -6,12 +6,18 @@ var _ = require('underscore') |
6 | 6 | |
7 | 7 | exports = module.exports = function(logger, settings) { |
8 | 8 | |
9 | - var connection = mongoose.createConnection( | |
10 | - settings.mongo.host, | |
11 | - settings.mongo.dbname, | |
12 | - settings.mongo.port, | |
13 | - settings.mongo.opts | |
14 | - ) | |
9 | + var connection | |
10 | + | |
11 | + if (_.isString(settings.mongo.uri)) { | |
12 | + connection = mongoose.createConnection(settings.mongo.uri, settings.mongo.opts) | |
13 | + } else { | |
14 | + connection = mongoose.createConnection( | |
15 | + settings.mongo.host, | |
16 | + settings.mongo.dbname, | |
17 | + settings.mongo.port, | |
18 | + settings.mongo.opts | |
19 | + ) | |
20 | + } | |
15 | 21 | |
16 | 22 | connection.on('error', function(err) { |
17 | 23 | logger.error('mongo connection error: %s', err.message || err) | ... | ... |
请
注册
或
登录
后发表评论