|
@@ -388,7 +388,7 @@ class MongodbHandler:
|
|
|
'''
|
|
|
return self._database[collection_name].find({query_label:query_value}).count() > 0
|
|
|
|
|
|
- def query_data_between_dates_and_generate_dataframe(self, collection_name: str, date_label: str = None, from_date_value: str = None, to_date_value: str = None, index: str = None, return_id: bool = False, return_as_dataframe: bool = True, find_query: dict = None):
|
|
|
+ def query_data_between_dates_and_generate_dataframe(self, collection_name: str, date_label: str = None, from_date_value: str = None, to_date_value: str = None, index: str = None, return_id: bool = False, return_as_dataframe: bool = True, find_query: dict = None, return_values: dict = None):
|
|
|
'''
|
|
|
Queries data between two dates.
|
|
|
|
|
@@ -402,6 +402,9 @@ class MongodbHandler:
|
|
|
assert(isinstance(collection_name, str)),\
|
|
|
"Parameter 'collection_name' must be a string type"
|
|
|
|
|
|
+ if return_values is None:
|
|
|
+ return_values = {'_id': return_id}
|
|
|
+
|
|
|
if date_label and from_date_value and to_date_value or find_query:
|
|
|
|
|
|
try:
|
|
@@ -411,7 +414,7 @@ class MongodbHandler:
|
|
|
else:
|
|
|
query = {date_label: {'$gt': from_date_value, '$lt': to_date_value}}
|
|
|
|
|
|
- data = self._database[collection_name].find(query, {'_id': return_id})
|
|
|
+ data = self._database[collection_name].find(query, return_values)
|
|
|
|
|
|
except Exception as error:
|
|
|
self._log.log_and_raise_error(('An error occured trying to query data from {}, with query {}. \nError:{}').format(collection_name, query, error))
|