updated map/reduce documentation
This commit is contained in:
		| @@ -388,27 +388,22 @@ class QuerySet(object): | |||||||
|         it must be the last call made, as it does not return a maleable  |         it must be the last call made, as it does not return a maleable  | ||||||
|         ``QuerySet``.  |         ``QuerySet``.  | ||||||
|              |              | ||||||
|         Example: map/reduce operation is given a ``QuerySet``  |         See the :meth:`~mongoengine.tests.QuerySetTest.test_map_reduce`  | ||||||
|         of all posts by "mattdennewitz", ordered by most recent "pub_date". :: |         and :meth:`~mongoengine.tests.QuerySetTest.test_map_advanced` | ||||||
|          |         tests in ``tests.queryset.QuerySetTest`` for usage examples. | ||||||
|             map_f = function() { ... } |  | ||||||
|             reduce_f = function(key, values) { ... } |  | ||||||
|          |  | ||||||
|             posts = BlogPost(author="mattdennewitz").order_by("-pub_date") |  | ||||||
|             tag_counts = posts.map_reduce(map_f, reduce_f) |  | ||||||
|              |  | ||||||
|         See the :meth:`~mongoengine.tests.QuerySetTest.test_map_reduce_simple`  |  | ||||||
|         unit test for more usage examples. |  | ||||||
|      |      | ||||||
|         :param map_f: map function, as :class:`~pymongo.code.Code` or string |         :param map_f: map function, as :class:`~pymongo.code.Code` or string | ||||||
|         :param reduce_f: reduce function, as  |         :param reduce_f: reduce function, as  | ||||||
|                          :class:`~pymongo.code.Code` or string |                          :class:`~pymongo.code.Code` or string | ||||||
|  |         :param finalize_f: finalize function, an optional function that | ||||||
|  |                            performs any post-reduction processing. | ||||||
|         :param scope: values to insert into map/reduce global scope. Optional. |         :param scope: values to insert into map/reduce global scope. Optional. | ||||||
|         :param limit: number of objects from current query to provide |         :param limit: number of objects from current query to provide | ||||||
|                       to map/reduce method |                       to map/reduce method | ||||||
|         :param keep_temp: keep temporary table (boolean, default ``True``) |         :param keep_temp: keep temporary table (boolean, default ``True``) | ||||||
|          |          | ||||||
|         Returns a list of :class:`~mongoengine.document.MapReduceDocument`. |         Returns an iterator yielding  | ||||||
|  |         :class:`~mongoengine.document.MapReduceDocument`. | ||||||
|          |          | ||||||
|         .. note:: Map/Reduce requires server version **>= 1.1.1**. The PyMongo |         .. note:: Map/Reduce requires server version **>= 1.1.1**. The PyMongo | ||||||
|            :meth:`~pymongo.collection.Collection.map_reduce` helper requires |            :meth:`~pymongo.collection.Collection.map_reduce` helper requires | ||||||
| @@ -416,8 +411,6 @@ class QuerySet(object): | |||||||
|             |             | ||||||
|         .. versionadded:: 0.2.2 |         .. versionadded:: 0.2.2 | ||||||
|  |  | ||||||
|         .. todo:: Implement limits |  | ||||||
|  |  | ||||||
|         """ |         """ | ||||||
|         from document import MapReduceDocument |         from document import MapReduceDocument | ||||||
|          |          | ||||||
|   | |||||||
| @@ -601,7 +601,10 @@ class QuerySetTest(unittest.TestCase): | |||||||
|         results = results.map_reduce(map_f, reduce_f, finalize_f=finalize_f) |         results = results.map_reduce(map_f, reduce_f, finalize_f=finalize_f) | ||||||
|         results = list(results) |         results = list(results) | ||||||
|          |          | ||||||
|  |         # assert troublesome Buzz article is ranked 1st | ||||||
|         self.assertTrue(results[0].object.title.startswith("Google Buzz")) |         self.assertTrue(results[0].object.title.startswith("Google Buzz")) | ||||||
|  |          | ||||||
|  |         # assert laser vision is ranked last | ||||||
|         self.assertTrue(results[-1].object.title.startswith("How to see")) |         self.assertTrue(results[-1].object.title.startswith("How to see")) | ||||||
|  |  | ||||||
|         Link.drop_collection() |         Link.drop_collection() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user