Get a :class:`~pymongo.asynchronous.collection.AsyncCollection` with the given name and options. Useful for creating a :class:`~pymongo.asynchronous.collection.AsyncCollection` with different codec options, read preference, and/or write concern from this :class:`Asyn
(
self,
name: str,
codec_options: Optional[CodecOptions[_DocumentTypeArg]] = None,
read_preference: Optional[_ServerMode] = None,
write_concern: Optional[WriteConcern] = None,
read_concern: Optional[ReadConcern] = None,
)
| 250 | return AsyncCollection(self, name) |
| 251 | |
| 252 | def get_collection( |
| 253 | self, |
| 254 | name: str, |
| 255 | codec_options: Optional[CodecOptions[_DocumentTypeArg]] = None, |
| 256 | read_preference: Optional[_ServerMode] = None, |
| 257 | write_concern: Optional[WriteConcern] = None, |
| 258 | read_concern: Optional[ReadConcern] = None, |
| 259 | ) -> AsyncCollection[_DocumentType]: |
| 260 | """Get a :class:`~pymongo.asynchronous.collection.AsyncCollection` with the given name |
| 261 | and options. |
| 262 | |
| 263 | Useful for creating a :class:`~pymongo.asynchronous.collection.AsyncCollection` with |
| 264 | different codec options, read preference, and/or write concern from |
| 265 | this :class:`AsyncDatabase`. |
| 266 | |
| 267 | >>> db.read_preference |
| 268 | Primary() |
| 269 | >>> coll1 = db.test |
| 270 | >>> coll1.read_preference |
| 271 | Primary() |
| 272 | >>> from pymongo import ReadPreference |
| 273 | >>> coll2 = db.get_collection( |
| 274 | ... 'test', read_preference=ReadPreference.SECONDARY) |
| 275 | >>> coll2.read_preference |
| 276 | Secondary(tag_sets=None) |
| 277 | |
| 278 | :param name: The name of the collection - a string. |
| 279 | :param codec_options: An instance of |
| 280 | :class:`~bson.codec_options.CodecOptions`. If ``None`` (the |
| 281 | default) the :attr:`codec_options` of this :class:`AsyncDatabase` is |
| 282 | used. |
| 283 | :param read_preference: The read preference to use. If |
| 284 | ``None`` (the default) the :attr:`read_preference` of this |
| 285 | :class:`AsyncDatabase` is used. See :mod:`~pymongo.read_preferences` |
| 286 | for options. |
| 287 | :param write_concern: An instance of |
| 288 | :class:`~pymongo.write_concern.WriteConcern`. If ``None`` (the |
| 289 | default) the :attr:`write_concern` of this :class:`AsyncDatabase` is |
| 290 | used. |
| 291 | :param read_concern: An instance of |
| 292 | :class:`~pymongo.read_concern.ReadConcern`. If ``None`` (the |
| 293 | default) the :attr:`read_concern` of this :class:`AsyncDatabase` is |
| 294 | used. |
| 295 | """ |
| 296 | return AsyncCollection( |
| 297 | self, |
| 298 | name, |
| 299 | False, |
| 300 | codec_options, |
| 301 | read_preference, |
| 302 | write_concern, |
| 303 | read_concern, |
| 304 | ) |
| 305 | |
| 306 | async def _get_encrypted_fields( |
| 307 | self, kwargs: Mapping[str, Any], coll_name: str, ask_db: bool |
no test coverage detected