How to remove all contents of database using MongoAlchemy

Viewed 365

As title suggests, I want to remove all contents of the database. I'm making an application in Python using Flask and MongoAlchemy for database. I have the class People which models the documents. The structure is:

class People(db.Document):
    Name = db.StringField()
    Age = db.IntField()
    Password = db.StringField()
    Vms = db.AnythingField()

With the remove method I can delete only one document at once, based on the name or other detail, but I want to be able to delete them all at once.

This is my function for deleting a document, based on name.

def delete_document(name):
    x = People.query.filter(People.Name == name).first()
    x.remove()

Where People is the reference to the model class.

1 Answers
Related