gpt4 book ai didi

node.js - 当使用 sails.js 关闭 mongodb 数据库连接时?

转载 作者:可可西里 更新时间:2023-11-01 09:52:14 26 4
gpt4 key购买 nike

我正在使用 sails-mongo 。

MongoLocal:{

module: 'sails-mongo',
host: 'localhost',
port : '27017',
user: '',
password: '',
database: 'test'

我想知道 sails.js 什么时候关闭 mongodb 的连接?

例如:目前,如果我有 10 个模型,则总连接数约为 70-90 个连接。我怎样才能使每个应用程序实例只有一个连接?

请帮忙。非常感谢。

最佳答案

我发现在sails-mongo的配置中有一个poolSize here sails-mongo 使用 Mongo native client其中有一个键 ma​​xPoolSize。还没有尝试过,但也许它是您正在寻找的东西

{
module: 'sails-mongo',
host: 'localhost',
port : '27017',
user: '',
password: '',
database: 'test',
maxPoolSize: 1,
poolSize: 1
}

关于node.js - 当使用 sails.js 关闭 mongodb 数据库连接时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23194356/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com