Skip to content

Commit

Permalink
Simplify data deletion in example app
Browse files Browse the repository at this point in the history
  • Loading branch information
insspb committed Aug 17, 2022
1 parent a26b95c commit 16e824c
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions example_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
from mongoengine.context_managers import switch_db

from example_app import models
from example_app.binary_demo import BinaryDemoModel
from example_app.boolean_demo import BooleanDemoModel
from example_app.dates_demo import DateTimeModel
from example_app.dict_demo import DictDemoModel
from example_app.numbers_demo import NumbersDemoModel
from example_app.strings_demo import StringsDemoModel


def generate_data():
Expand Down Expand Up @@ -51,16 +45,11 @@ def generate_data():

def delete_data():
"""Clear database."""
with switch_db(models.Todo, "default"):
models.Todo.objects().delete()
BooleanDemoModel.objects().delete()
DateTimeModel.objects().delete()
DictDemoModel.objects().delete()
StringsDemoModel.objects().delete()
NumbersDemoModel.objects().delete()
BinaryDemoModel.objects().delete()
with switch_db(models.Todo, "secondary"):
models.Todo.objects().delete()
from example_app.app import db

connection = db.connection
connection["default"].drop_database("example_app")
connection["secondary"].drop_database("example_app_2")


def index():
Expand Down

0 comments on commit 16e824c

Please sign in to comment.