Remove all entries associated with a specific source. If an entry is associated with multiple sources, then only the association with the specified source will be removed. :param source: The source references that are to be removed. :return: A boolean indica
(self, source)
| 345 | return True |
| 346 | |
| 347 | def remove_by_source(self, source): |
| 348 | """ |
| 349 | Remove all entries associated with a specific source. |
| 350 | If an entry is associated with multiple sources, |
| 351 | then only the association with the specified source will be removed. |
| 352 | |
| 353 | :param source: The source references that are to be removed. |
| 354 | :return: A boolean indicating success or failure |
| 355 | """ |
| 356 | results = self.all_dns_collection.find({"sources.source": source}) |
| 357 | |
| 358 | if results is None: |
| 359 | return False |
| 360 | |
| 361 | for result in results: |
| 362 | if len(result["sources"]) == 1: |
| 363 | self.all_dns_collection.delete_one({"_id": ObjectId(result["_id"])}) |
| 364 | else: |
| 365 | self.all_dns_collection.update_one( |
| 366 | {"_id": ObjectId(result["_id"])}, |
| 367 | {"$pull": {"sources": {"source": source}}}, |
| 368 | ) |
| 369 | return True |