Preview:
# 1- > Deleting based on _id in baselineTable

from bson import ObjectId
import json

file_path = 'delete_ids'

with open(file_path, 'r') as file:
    data = json.load(file)

data_array = data['data']

delete_object_ids = [ObjectId(item) for item in data_array]
db["participantBaselineAndFollowupData"].delete_many({"_id": {"$in": delete_object_ids}})
#to check
# records = db["participantBaselineAndFollowupData"].find({"_id": {"$in": delete_object_ids}})
# count=0
# for record in records:
#     count=count+1
#     print(record["_id"])
# print(count)
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter