I am having trouble saving documents to a new collection and then deleting them from the old one. I create a new object like so:
class Test(mongo.Document):
field = mongo.StringField()
t = Test(field="test")
t.switch_collection('default')
t.save()
t.switch_collection('switched')
t.save()
t.switch_collection('default')
t.delete()
It seems only to perform the first save to the default collection and then performs nothing after that. I have played around with a bunch of difference options such as reloading the object after every switch/save and from mongoengine context managers:
with switch_collection(Test, 'mongoswitch') as test:
test(field="switch").save()
My mongo settings look like (called first):
app.config["MONGODB_SETTINGS"] = {'db': 'TestDB'}
mongo = MongoEngine(app)
Using mongoengine 0.10 and pymongo 2.8.1 with Python 3.4 .
Anyone have an idea? Much Thanks.