No meu computador, está dando este erro.
MongoServerError: BSON size limit hit while building Message. Size: 26572381 (0x195765D); maxSize: 16793600(16MB)
at Connection.onMessage (C:\sistemas\workspace\graficos\graficos_backend\node_modules\mongodb\lib\cmap\connection.js:202:26)
at MessageStream.<anonymous> (C:\sistemas\workspace\graficos\graficos_backend\node_modules\mongodb\lib\cmap\connection.js:61:60)
at MessageStream.emit (node:events:513:28)
at processIncomingData (C:\sistemas\workspace\graficos\graficos_backend\node_modules\mongodb\lib\cmap\message_stream.js:124:16)
at MessageStream._write (C:\sistemas\workspace\graficos\graficos_backend\node_modules\mongodb\lib\cmap\message_stream.js:33:9)
at writeOrBuffer (node:internal/streams/writable:391:12)
at _write (node:internal/streams/writable:332:10)
at MessageStream.Writable.write (node:internal/streams/writable:336:10)
at Socket.ondata (node:internal/streams/readable:754:22)
at Socket.emit (node:events:513:28) {
ok: 0,
code: 10334,
codeName: 'BSONObjectTooLarge',
[Symbol(errorLabels)]: Set(0) {}
}
Código de pesquisa:
const aggregationCursor = repo.aggregate(
[
{
$match: params
},
{
$group: {
_id: groupBy.reduce(
(prev, act) => ({ ...prev, [act]: `$${act}` }),
{}
),
...aggregationFactory(options, aggregationKey)
}
},
{
$project: {
groupedBy: '$_id',
...Object.keys(options).reduce(
(prev, actKey) => ({ ...prev, [actKey]: `$${actKey}` }),
{}
),
aggregationKey
}
}
],
{ allowDiskUse: true }
)
Como ajustar ?