我正在尝试查询并打印出我的收藏集中的结果,但是它太大了,并且批处理仅返回前几百个结果。
我尝试使用batchSize来提高限制,但是每次我尝试将其实现到脚本中时都会出错。
我期望结果的数量约为15000条记录。
我正在运行如下的.js脚本:
db = db.getSiblingDB('local');
print("START");
result = (db.idlsfcontractroles.aggregate([
{"$lookup":{
"from":"idlsfcontracts",
"localField":"Contract__r_ExternalId__c",
"foreignField":"ExternalId__c",
"as":"Con"
}},
{"$unwind":"$Con"},
{"$match":{"Con.Status__c":1,"Con.Type__c":1,"Con.ConductingCompany__c":9}},
{"$group":{"_id":"$Account__r_MDMExternalId__c"}}
]));
printjson(result);
答案 0 :(得分:0)
使用跳过/限制页面浏览结果,直到完成。
var skip = 0;
do {
result = (db.idlsfcontractroles.aggregate([
{"$lookup":{
"from":"idlsfcontracts",
"localField":"Contract__r_ExternalId__c",
"foreignField":"ExternalId__c",
"as":"Con"
}},
{"$unwind":"$Con"},
{"$skip": skip},
{"$limit": 100},
{"$match":
{"Con.Status__c":1,"Con.Type__c":1,"Con.ConductingCompany__c":9}},
{"$group":{"_id":"$Account__r_MDMExternalId__c"}}
]))
printjson(result);
skip += 100;
} while (result)