Limit the number of documents returned in a single batch (each batch requires a round trip to the server). See https://pymongo.readthedocs.io/en/stable/api/pymongo/cursor.html#pymongo.cursor.Cursor for details. :param size: desired size of each batch.
(self, size)
| 960 | return queryset |
| 961 | |
| 962 | def batch_size(self, size): |
| 963 | """Limit the number of documents returned in a single batch (each |
| 964 | batch requires a round trip to the server). |
| 965 | |
| 966 | See https://pymongo.readthedocs.io/en/stable/api/pymongo/cursor.html#pymongo.cursor.Cursor |
| 967 | for details. |
| 968 | |
| 969 | :param size: desired size of each batch. |
| 970 | """ |
| 971 | queryset = self.clone() |
| 972 | queryset._batch_size = size |
| 973 | |
| 974 | # If a cursor object has already been created, apply the batch size to it. |
| 975 | if queryset._cursor_obj: |
| 976 | queryset._cursor_obj.batch_size(queryset._batch_size) |
| 977 | |
| 978 | return queryset |
| 979 | |
| 980 | def distinct(self, field): |
| 981 | """Return a list of distinct values for a given field. |