提交 61eec9106c5a6c0669df8e55bbb8ad37afe13527

作者 Nick Baugh
1 个父辈 7a41f07b

added support for mongo uri

正在显示 1 个修改的文件 包含 12 行增加6 行删除
@@ -6,12 +6,18 @@ var _ = require('underscore') @@ -6,12 +6,18 @@ var _ = require('underscore')
6 6
7 exports = module.exports = function(logger, settings) { 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 connection.on('error', function(err) { 22 connection.on('error', function(err) {
17 logger.error('mongo connection error: %s', err.message || err) 23 logger.error('mongo connection error: %s', err.message || err)
注册登录 后发表评论