db.entities.aggregate([
{$limit: 80000},
{$unwind: '$documents'},
{$unwind: '$documents.subjects'},
{$unwind: '$documents.subjects.journal_entries'},
{$match: {'documents.subjects.journal_entries.date':{$gte: ISODate("2014-01-01T00:00:00.0Z"), $lte: ISODate("2015-01-01T00:00:00.0Z")}}},
{$group: {_id: "$_id", "total": {$sum: '$documents.subjects.journal_entries.amount'}}},
]);
这是我的聚合器查询。它输出一个带有字段结果的文档,结果字段有行。每行基本上都是一个文档。
我希望每一行都是自己的文档。我将查询大量的行,Mongo的这种行为会破坏我的查询,因为它超过了文档的最大大小(16Mb)。
我怎样才能做到这一点?
编辑:
当前输出:
{
results: [
{_id: ..., total: ...},
{_id: ..., total: ...}
{_id: ..., total: ...}
{_id: ..., total: ...}
{_id: ..., total: ...}
{_id: ..., total: ...}
]
}
预期产出:
{_id: ..., total: ...};
{_id: ..., total: ...};
{_id: ..., total: ...};
{_id: ..., total: ...};
{_id: ..., total: ...};
{_id: ..., total: ...};
分号是新文档的分隔符