method finds Site Statistics record and update it DB representation

def update(self, collection_name, instance):
        """ method finds Site Statistics record and update it DB representation """
        assert isinstance(instance, SiteStatistics)
        if instance.db_id:
            query = {'_id': ObjectId(instance.db_id)}
        else:
            query = {DOMAIN_NAME: instance.domain_name,
                     TIMEPERIOD: instance.timeperiod}
        self.ds.update(collection_name, query, instance)
        return instance.db_id