MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / __getattr__

Method __getattr__

pymongo/asynchronous/collection.py:268–281  ·  view source on GitHub ↗

Get a sub-collection of this collection by name. Raises InvalidName if an invalid collection name is used. :param name: the name of the collection to get

(self, name: str)

Source from the content-addressed store, hash-verified

266 )
267
268 def __getattr__(self, name: str) -> AsyncCollection[_DocumentType]:
269 """Get a sub-collection of this collection by name.
270
271 Raises InvalidName if an invalid collection name is used.
272
273 :param name: the name of the collection to get
274 """
275 if name.startswith("_"):
276 full_name = f"{self._name}.{name}"
277 raise AttributeError(
278 f"{type(self).__name__} has no attribute {name!r}. To access the {full_name}"
279 f" collection, use database['{full_name}']."
280 )
281 return self.__getitem__(name)
282
283 def __getitem__(self, name: str) -> AsyncCollection[_DocumentType]:
284 return AsyncCollection(

Callers

nothing calls this directly

Calls 1

__getitem__Method · 0.95

Tested by

no test coverage detected