Multiple node-mongodb-native connections

a 夏天 提交于 2019-12-02 03:18:06

Sure. MongoClient uses the connection pools option from the node native driver. This is actually really a Server Object and the number of connections is 5 by default.

You can override the setting like this:

var async = require('async'),
    mongo = require('mongo'),
    MongoClient = mongo.MongoClient;


MongoClient.connect('mongodb://localhost/test',{ server: { poolSize: 1  }},function(err,db) {


});

So setting "poolSize" in the server options specifies the number of connections used in the pool. Best to stick with the default or higher really though.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!