|
@@ -516,6 +516,20 @@ class MongodbHandler:
|
|
|
except Exception as error:
|
|
|
self._log.log_and_raise_error(('There was a problem updating data for label: {}, Error: {}').format(update_label, error))
|
|
|
|
|
|
+ def which_document_in_list_exists(self, collection_name: str, query_label: str, query_values:list):
|
|
|
+ '''
|
|
|
+ Checking whether the document in the list exist or not.
|
|
|
+ :param str collection_name: collection to add data to
|
|
|
+ :param str query_label: label for the query
|
|
|
+ :param list query_values: values to see if they exist or not
|
|
|
+ '''
|
|
|
+
|
|
|
+ query = {query_label:{'$in': query_values}}
|
|
|
+ data = self._database[collection_name].find(query,{query_label:1, '_id':0})
|
|
|
+ if data.collection.count_documents(query) != 0:
|
|
|
+ return [value[query_label] for value in data]
|
|
|
+ else:<
|
|
|
+ return []
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|