MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / drop_collection

Method drop_collection

mongoengine/document.py:862–876  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Calls 3

OperationErrorClass · 0.85
_get_dbMethod · 0.80
_get_collection_nameMethod · 0.45