Limit the number of returned documents to `n`. This may also be achieved using array-slicing syntax (e.g. ``User.objects[:5]``). :param n: the maximum number of objects to return if n is greater than 0. When 0 is passed, returns all the documents in the cursor
(self, n)
| 882 | return queryset._dereference(queryset, max_depth=max_depth) |
| 883 | |
| 884 | def limit(self, n): |
| 885 | """Limit the number of returned documents to `n`. This may also be |
| 886 | achieved using array-slicing syntax (e.g. ``User.objects[:5]``). |
| 887 | |
| 888 | :param n: the maximum number of objects to return if n is greater than 0. |
| 889 | When 0 is passed, returns all the documents in the cursor |
| 890 | """ |
| 891 | queryset = self.clone() |
| 892 | queryset._limit = n |
| 893 | queryset._empty = False # cancels the effect of empty |
| 894 | |
| 895 | # If a cursor object has already been created, apply the limit to it. |
| 896 | if queryset._cursor_obj: |
| 897 | queryset._cursor_obj.limit(queryset._limit) |
| 898 | |
| 899 | return queryset |
| 900 | |
| 901 | def skip(self, n): |
| 902 | """Skip `n` documents before returning the results. This may also be |