Is there any way to supply the allowDiskUse option to an mongoose.js aggregation?
Model.aggregate(..).allowDiskUse(true).exec(callback)
We don't have a helper for this right now, but an allowDiskUse()
helper function will be included in Mongoose 3.8.12, which I'll ship today: https://github.com/LearnBoost/mongoose/issues/2114
If you want an immediate solution or don't want to upgrade to 3.8.12 (although upgrading is recommended), you can do something like:
var aggregation = MyModel.aggregate(...); aggregation.options = { allowDiskUse: true }; aggregation.exec(function() {});
const agg = Model.aggregate(..).option({ allowDiskUse: true });
worked for me as per the Mongoose V6.0.4 documentation here