Is there a way to provide the allowDiskUse parameter for mongoose.js aggregation?

I run aggregation in a collection of about 300k + records, which requires several breaks and groups. I find an error:

'exception: Exceeded memory limit for $group, but didn\'t allow external sort. Pass allowDiskUse:true to opt in.' 

I cannot figure out how to pass this parameter using mongoose.js API?

+8
mongodb mongoose aggregation-framework
source share
2 answers

We don’t have a helper right now, but the helper function allowDiskUse() will be included in Mongoose 3.8.12, which I will post today: https://github.com/LearnBoost/mongoose/issues/2114

If you want an immediate solution or do not want to upgrade to 3.8.12 (although an update is recommended), you can do something like:

 var aggregation = MyModel.aggregate(...); aggregation.options = { allowDiskUse: true }; aggregation.exec(function() {}); 
+13
source share
 Model.aggregate(..).allowDiskUse(true).exec(callback) 

mongoose api

+5
source share

All Articles