示例#1
0
    def update_band(cls, user_id, follow_count, transaction):
        band_data = ArangoCore.get_vertex_in_collection(
            ArangoVertex.BAND, user_id)
        band_data['follow_count'] = follow_count

        ArangoCore.update_vertex_in_collection(ArangoVertex.BAND, band_data,
                                               transaction)
        band_data['_id'] = '{0}/{1}'.format('rv_users', user_id)
        ArangoCore.update_vertex_in_collection(ArangoVertex.USER, band_data,
                                               transaction)
示例#2
0
    def save_user(cls, user_id, user_data=None, is_new=True):
        try:
            user_data = cls.prepare_data_to_save(user_id, user_data, is_new)
            database = ArangoCore.get_database()
            collections = [ArangoVertex.USER]
            with database.transaction(write=collections,
                                      commit_on_error=False) as transaction:
                if is_new:
                    ArangoCore.add_vertex_to_collection(
                        ArangoVertex.USER, user_data, transaction)
                else:
                    ArangoCore.update_vertex_in_collection(
                        ArangoVertex.USER, user_data, transaction)
                    user_data['_id'] = '{0}/{1}'.format(
                        'rv_users', user_data['id'])

                transaction.commit()
            return True
        except Exception as exception:
            raise exception