⚠ Documentation version

These are the Git version docs. Docs for 0.4 (PyPI) are here.

Help out!

To make this documentation even better, we'd love to receive your feedback and suggestions for improvement!

Map/Reduce

from django_mongodb_engine.contrib import MongoDBManager

class MapReduceableModel(models.Model):
    ...
    objects = MongoDBManager()
>>> MapReduceableModel.objects.filter(...).map_reduce(...)
MongoDBQuerySet.map_reduce(...)

Performs a Map/Reduce operation on all documents matching the query, yielding a MapReduceResult object for each result entity.

If the optional keyword argument drop_collection is True, the result collection will be dropped after fetching all results.

Any other arguments are passed to Collection.map_reduce.

MongoDBQuerySet.inline_map_reduce(...)

Similar to map_reduce() but runs the Map/Reduce in memory, returning a list of MapReduceResults.

Does not take the drop_collection keyword argument since no result collection is involved for in-memory Map/Reduce operations.

class django_mongodb_engine.contrib.MapReduceResult(model, key, value)

Represents one item of a MapReduce result array.

Parameters:
  • model – the model on that query the MapReduce was performed
  • key – the key from the result item
  • value – the value from the result item