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

Method drop_collection

pymongo/asynchronous/database.py:1281–1356  ·  view source on GitHub ↗

Drop a collection. :param name_or_collection: the name of a collection to drop or the collection object itself :param session: a :class:`~pymongo.asynchronous.client_session.AsyncClientSession`. :param comment: A user-provided comment to attach to thi

(
        self,
        name_or_collection: Union[str, AsyncCollection[_DocumentTypeArg]],
        session: Optional[AsyncClientSession] = None,
        comment: Optional[Any] = None,
        encrypted_fields: Optional[Mapping[str, Any]] = None,
    )

Source from the content-addressed store, hash-verified

1279
1280 @_csot.apply
1281 async def drop_collection(
1282 self,
1283 name_or_collection: Union[str, AsyncCollection[_DocumentTypeArg]],
1284 session: Optional[AsyncClientSession] = None,
1285 comment: Optional[Any] = None,
1286 encrypted_fields: Optional[Mapping[str, Any]] = None,
1287 ) -> dict[str, Any]:
1288 """Drop a collection.
1289
1290 :param name_or_collection: the name of a collection to drop or the
1291 collection object itself
1292 :param session: a
1293 :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
1294 :param comment: A user-provided comment to attach to this
1295 command.
1296 :param encrypted_fields: **(BETA)** Document that describes the encrypted fields for
1297 Queryable Encryption. For example::
1298
1299 {
1300 "escCollection": "enxcol_.encryptedCollection.esc",
1301 "ecocCollection": "enxcol_.encryptedCollection.ecoc",
1302 "fields": [
1303 {
1304 "path": "firstName",
1305 "keyId": Binary.from_uuid(UUID('00000000-0000-0000-0000-000000000000')),
1306 "bsonType": "string",
1307 "queries": {"queryType": "equality"}
1308 },
1309 {
1310 "path": "ssn",
1311 "keyId": Binary.from_uuid(UUID('04104104-1041-0410-4104-104104104104')),
1312 "bsonType": "string"
1313 }
1314 ]
1315
1316 }
1317
1318
1319 .. note:: The :attr:`~pymongo.asynchronous.database.AsyncDatabase.write_concern` of
1320 this database is automatically applied to this operation.
1321
1322 .. versionchanged:: 4.2
1323 Added ``encrypted_fields`` parameter.
1324
1325 .. versionchanged:: 4.1
1326 Added ``comment`` parameter.
1327
1328 .. versionchanged:: 3.6
1329 Added ``session`` parameter.
1330
1331 .. versionchanged:: 3.4
1332 Apply this database's write concern automatically to this operation
1333 when connected to MongoDB >= 3.4.
1334
1335 """
1336 name = name_or_collection
1337 if isinstance(name, AsyncCollection):
1338 name = name.name

Callers 4

test_list_collectionsMethod · 0.95
test_drop_collectionMethod · 0.95
dropMethod · 0.45

Calls 4

_get_encrypted_fieldsMethod · 0.95
_drop_helperMethod · 0.95
_esc_coll_nameFunction · 0.90
_ecoc_coll_nameFunction · 0.90

Tested by 3

test_list_collectionsMethod · 0.76
test_drop_collectionMethod · 0.76