mongokit

mongokit remove all items from collection


I would like to remove all items from a test collection. My setup is

connection = Connection(app.config['MONGODB_HOST'], app.config['MONGODB_PORT'])
db = connection.test_database.tutorial

I have a document model class Test which maps to the tests collection. I've tried deleting the collection with both

connection.test_database.drop_collection('tutorial.tests')
db.tests.remove()

However querying something like

list(db.Test.find())

still gives me the old data. Something like

list(db.tests.find())

returns an empty list. However if I add new entries into tests the previous query also doesn't reflect the changes, so I don't think thats accurate either.


Solution

  • Problem was with this line: db = connection.test_database.tutorial Since it was saying test database and the tutorial collection

    removing worked when I changed it to db = connection.tutorial