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,
)
| 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 |