如何在nodejs中增加mongoose的连接

时间:2016-05-09 10:25:04

标签: node.js mongodb mongoose

我需要同时运行10个查询。我如何在我的nodejs应用程序中执行此操作。我现在正在做的是

var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/testdb', function(err) {
if(err) {
    console.log(err);
} else {
    console.log('Connected to the database');
}
});

我该怎么做才能解决问题。或者我应该在db配置中更改某些内容。

1 个答案:

答案 0 :(得分:0)

您可以在连接时增加池大小。试试这个

var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/testdb', {server: { poolSize: 50 }}, function(err) {
if(err) {
    console.log(err);
} else {
    console.log('Connected to the database');
}
}); 
相关问题