Search code examples
pythonmongodbmongoengine

mongoengine enable "allowDiskUse"


Is there an option to allow disk use in mongoengine? I could not find any resources online.

I tried

model.objects.aggregate(pipeline, {'allowDiskUse': True})

which throws:

Each element of the 'pipeline' array must be an object

Solution

  • Pass it as keyword argument. Mongoengine then passes all keyword arguments further to pymongo's aggregate method

    model.objects.aggregate(*pipeline, allowDiskUse=True)