TH / app / utils / trx / delete_trxs_with_no_trxs.py
delete_trxs_with_no_trxs.py
Raw
from pymongo import errors
from typing import List, Dict

from models import TrxWithNoLabels


def delete_trxs(
    trxs: List[Dict]
):
    client = TrxWithNoLabels.mongo_client()
    for trx in trxs:
        try:
            query = {"chainIdHash": f'{trx.get("chainId")}_{trx.get("hash")}'}
            client.delete_one(query)
        except errors.PyMongoError:
            continue