MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / collation

Method collation

pymongo/synchronous/cursor.py:848–861  ·  view source on GitHub ↗

Adds a :class:`~pymongo.collation.Collation` to this query. Raises :exc:`TypeError` if `collation` is not an instance of :class:`~pymongo.collation.Collation` or a ``dict``. Raises :exc:`~pymongo.errors.InvalidOperation` if this :class:`Cursor` has already been used.

(self, collation: Optional[_CollationIn])

Source from the content-addressed store, hash-verified

846 return self
847
848 def collation(self, collation: Optional[_CollationIn]) -> Cursor[_DocumentType]:
849 """Adds a :class:`~pymongo.collation.Collation` to this query.
850
851 Raises :exc:`TypeError` if `collation` is not an instance of
852 :class:`~pymongo.collation.Collation` or a ``dict``. Raises
853 :exc:`~pymongo.errors.InvalidOperation` if this :class:`Cursor` has
854 already been used. Only the last collation applied to this cursor has
855 any effect.
856
857 :param collation: An instance of :class:`~pymongo.collation.Collation`.
858 """
859 self._check_okay_to_chain()
860 self._collation = validate_collation_or_none(collation)
861 return self
862
863 def _unpack_response(
864 self,

Callers 2

test_cursor_collationMethod · 0.45
test_cursor_collationMethod · 0.45

Calls 2

_check_okay_to_chainMethod · 0.95

Tested by 2

test_cursor_collationMethod · 0.36
test_cursor_collationMethod · 0.36