def get_next_id(self):
        try:
            query = {'_id': 'last_id'}
            update = {'$inc': {'id': 1}}
            fn = self.db.internal.find_and_modify
            row = fn(query, update, upsert=True, new=True)
        except Exception as e:
            raise DatabaseException(e)
        return row['id']
def update(self, *args, **kwargs):
        chain = []
        for arg in args:
            if isinstance(arg, dict):
                iterator = arg.items()
            else:
                iterator = arg
            chain = itertools.chain(chain, iterator)
        if kwargs:
            chain = itertools.chain(chain, kwargs.items())
        for key, value in iterator:
            self._collection[key] = self._from_python(key, value)