mongodb 有一个坑 报错 no mongos proxies found in seed list

mongoose 的报当我从 mongoose@4.5.2 升级到 mongoose@4.6.5的时候,出现了一个问题:

Unhandled rejection MongoError: no mongos proxies found in seed list

怎么办,我google 一下的时候发现:

  https://github.com/christkv/mongodb-core/issues/118

原来是mongo的一个bug

 

 

哎呦!看下源码,这是mongoose@4.6.5

Mongoose.prototype.createConnection = function(uri, options) {
var conn = new Connection(this);
this.connections.push(conn);

var rsOption = options && (options.replset || options.replSet);
if (arguments.length) {
if (rgxReplSet.test(arguments[0]) || checkReplicaSetInUri(arguments[0])) {
conn.openSet.apply(conn, arguments);
} else if (rsOption &&
(rsOption.replicaSet || rsOption.rs_name)) {
conn.openSet.apply(conn, arguments);
} else {
conn.open.apply(conn, arguments);
}
}

return conn;
};
再看下低版本的mongoose@4.5.2
Mongoose.prototype.createConnection = function(uri, options) {
var conn = new Connection(this);
this.connections.push(conn);

if (arguments.length) {
if (rgxReplSet.test(arguments[0]) || checkReplicaSetInUri(arguments[0])) {
conn.openSet.apply(conn, arguments);
} else if (options && options.replset &&
(options.replset.replicaSet || options.replset.rs_name)) {
conn.openSet.apply(conn, arguments);
} else {
conn.open.apply(conn, arguments);
}
}

return conn;
};
也就是说,在低版本中,你的mongodb 做了复制集的配置和不做复制集的配置都能连接到mongodb,在高本中如果你做了复制集,options 中的参数需要加一个
replset或者replSet S为true,而没有做复制集的要为false。

 

转载于:https://www.cnblogs.com/Kellana/p/6004767.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值