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

Method drop_collection

pymongo/synchronous/database.py:1278–1353  ·  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.client_session.ClientSession`. :param comment: A user-provided comment to attach to this comm

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

Source from the content-addressed store, hash-verified

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

Callers 15

test_list_collectionsMethod · 0.95
test_drop_collectionMethod · 0.95
test_threadingMethod · 0.45
test_safe_insertMethod · 0.45
test_safe_updateMethod · 0.45
test_snapshot_queryMethod · 0.45
drop_collectionsFunction · 0.45
test_socket_timeoutMethod · 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 15

test_list_collectionsMethod · 0.76
test_drop_collectionMethod · 0.76
test_threadingMethod · 0.36
test_safe_insertMethod · 0.36
test_safe_updateMethod · 0.36
test_snapshot_queryMethod · 0.36
test_socket_timeoutMethod · 0.36
test_tz_awareMethod · 0.36