Drops the entire collection associated with this :class:`~mongoengine.Document` type from the database. Raises :class:`OperationError` if the document has no collection set (i.g. if it is `abstract`)
(cls)
| 860 | |
| 861 | @classmethod |
| 862 | def drop_collection(cls): |
| 863 | """Drops the entire collection associated with this |
| 864 | :class:`~mongoengine.Document` type from the database. |
| 865 | |
| 866 | Raises :class:`OperationError` if the document has no collection set |
| 867 | (i.g. if it is `abstract`) |
| 868 | """ |
| 869 | coll_name = cls._get_collection_name() |
| 870 | if not coll_name: |
| 871 | raise OperationError( |
| 872 | "Document %s has no collection defined (is it abstract ?)" % cls |
| 873 | ) |
| 874 | cls._collection = None |
| 875 | db = cls._get_db() |
| 876 | db.drop_collection(coll_name) |
| 877 | |
| 878 | @classmethod |
| 879 | def create_index(cls, keys, background=False, **kwargs): |