'Temporarily switch the collection for a document instance.
Only really useful for archiving off data and calling `save()`::
user = User.objects.get(id=user_id)
user.switch_collection(\'old-users\')
user.save()
:param str collection_name: The database alias to use for saving the
document
:param bool keep_created: keep self._created value after switching collection, else is reset to True
.. seealso::
Use :class:`~mongoengine.context_managers.switch_db`
if you need to read from another database'

def switch_collection(self, collection_name, keep_created=True):

    with switch_collection(self.__class__, collection_name) as cls:
        collection = cls._get_collection()
    self._get_collection = (lambda : collection)
    self._collection = collection
    self._created = (True if (not keep_created) else self._created)
    self.__objects = self._qs
    self.__objects._collection_obj = collection
    return self
