我一直在使用 MongoSkin( Nodejs ) 插件来连接 Mongodb,如下所示。
var db = mongo.db(dbconfig.mongo_ip+'/'+dbconfig.mongo_db_name);
db.collection('myprofile').findOne({_id:memberid}, function(err, session){
if(err){
db.close();
console.log(err.stack);
}
})
如果我从 node.js 得到 mongo 连接错误,那么我如何使用 mongoskin 重新连接,
Mongo Connect errr: Error: failed to connect to [localhost:27017]
at [object Object].<anonymous> (/usr/local/lib/node_modules/mongoskin/node_modules/mongodb/lib/mongodb/connection/server.js:184:51)
at [object Object].emit (events.js:45:17)
at [object Object].<anonymous> (/usr/local/lib/node_modules/mongoskin/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:110:14)
at [object Object].emit (events.js:45:17)
at Socket.<anonymous> (/usr/local/lib/node_modules/mongoskin/node_modules/mongodb/lib/mongodb/connection/connection.js:301:10)
at Socket.emit (events.js:42:17)
at Array.33 (net.js:799:27)
at EventEmitter._tickCallback (node.js:108:26)
请帮助我。