我可以使用下面的命令更改mongodb的sort-buffer-size
db.adminCommand({setParameter: 1, internalQueryExecMaxBlockingSortBytes: <limit in bytes>})
但是,如何使用Mongoose库运行相同的命令?
最佳答案
试试这个:
YourModel.db.db.admin().command({setParameter: 1, internalQueryExecMaxBlockingSortBytes: <limit in bytes>}, function (err,res)
{
console.log(res);
});
更新:
您也可以不使用
YourModel
。mongoose.connection.db.admin().command({setParameter: 1, internalQueryExecMaxBlockingSortBytes: 268435456}, function (err,result)
{
console.log(result);
});
只需确保在建立连接后执行此操作。