|
22 | 22 | from pymongo.helpers import _gen_index_name, _index_document, _index_list |
23 | 23 | from pymongo.typings import _CollationIn, _DocumentType, _Pipeline |
24 | 24 |
|
| 25 | +# Hint supports index name, "myIndex", or list of either strings or index pairs: [('x', 1), ('y', -1), 'z''] |
| 26 | +_IndexList = Sequence[Union[str, Tuple[str, Union[int, str, Mapping[str, Any]]]]] |
| 27 | +_IndexKeyHint = Union[str, _IndexList] |
| 28 | + |
25 | 29 |
|
26 | 30 | class InsertOne(Generic[_DocumentType]): |
27 | 31 | """Represents an insert_one operation.""" |
@@ -55,10 +59,6 @@ def __ne__(self, other: Any) -> bool: |
55 | 59 | return not self == other |
56 | 60 |
|
57 | 61 |
|
58 | | -_IndexList = Sequence[Tuple[str, Union[int, str, Mapping[str, Any]]]] |
59 | | -_IndexKeyHint = Union[str, _IndexList] |
60 | | - |
61 | | - |
62 | 62 | class DeleteOne(object): |
63 | 63 | """Represents a delete_one operation.""" |
64 | 64 |
|
@@ -435,7 +435,9 @@ def __init__(self, keys: _IndexKeyHint, **kwargs: Any) -> None: |
435 | 435 |
|
436 | 436 | For use with :meth:`~pymongo.collection.Collection.create_indexes`. |
437 | 437 |
|
438 | | - Takes either a single key or a list of (key, direction) pairs. |
| 438 | + Takes either a single key or a list containing (key, direction) pairs |
| 439 | + or keys. If no direction is given, :data:`~pymongo.ASCENDING` will |
| 440 | + be assumed. |
439 | 441 | The key(s) must be an instance of :class:`basestring` |
440 | 442 | (:class:`str` in python 3), and the direction(s) must be one of |
441 | 443 | (:data:`~pymongo.ASCENDING`, :data:`~pymongo.DESCENDING`, |
@@ -477,8 +479,8 @@ def __init__(self, keys: _IndexKeyHint, **kwargs: Any) -> None: |
477 | 479 | server version. |
478 | 480 |
|
479 | 481 | :Parameters: |
480 | | - - `keys`: a single key or a list of (key, direction) |
481 | | - pairs specifying the index to create |
| 482 | + - `keys`: a single key or a list containing (key, direction) pairs |
| 483 | + or keys specifying the index to create |
482 | 484 | - `**kwargs` (optional): any additional index creation |
483 | 485 | options (see the above list) should be passed as keyword |
484 | 486 | arguments |
|
0 commit comments