Adds ``max`` operator that specifies upper bound for specific index. When using ``max``, :meth:`~hint` should also be configured to ensure the query uses the expected index and starting in MongoDB 4.2 :meth:`~hint` will be required. :param spec: a list of field, lim
(self, spec: _Sort)
| 642 | return self |
| 643 | |
| 644 | def max(self, spec: _Sort) -> Cursor[_DocumentType]: |
| 645 | """Adds ``max`` operator that specifies upper bound for specific index. |
| 646 | |
| 647 | When using ``max``, :meth:`~hint` should also be configured to ensure |
| 648 | the query uses the expected index and starting in MongoDB 4.2 |
| 649 | :meth:`~hint` will be required. |
| 650 | |
| 651 | :param spec: a list of field, limit pairs specifying the exclusive |
| 652 | upper bound for all keys of a specific index in order. |
| 653 | |
| 654 | .. versionchanged:: 3.8 |
| 655 | Deprecated cursors that use ``max`` without a :meth:`~hint`. |
| 656 | |
| 657 | .. versionadded:: 2.7 |
| 658 | """ |
| 659 | if not isinstance(spec, (list, tuple)): |
| 660 | raise TypeError(f"spec must be an instance of list or tuple, not {type(spec)}") |
| 661 | |
| 662 | self._check_okay_to_chain() |
| 663 | self._max = dict(spec) |
| 664 | return self |
| 665 | |
| 666 | def min(self, spec: _Sort) -> Cursor[_DocumentType]: |
| 667 | """Adds ``min`` operator that specifies lower bound for specific index. |