|
@@ -103,7 +103,7 @@ class MongodbHandler:
|
|
|
self._client.drop_database(self._database_name)
|
|
|
except Exception as error:
|
|
|
self._log.log_and_raise_error(('Couldnt drop the database. Error: {}').format(error))
|
|
|
-
|
|
|
+
|
|
|
|
|
|
def drop_collection(self, collection_name: str):
|
|
|
'''
|
|
@@ -114,7 +114,7 @@ class MongodbHandler:
|
|
|
self._log.warning(('Couldnt drop the collection {}. Error: {}').format(collection_name, return_message['errmsg']))
|
|
|
except Exception as error:
|
|
|
self._log.log_and_raise_error(('Couldnt drop the collection {}. Error: {}').format(collection_name, error))
|
|
|
-
|
|
|
+
|
|
|
def create_index(self, collection_name: str, key: str, direction: (str, int)='text'):
|
|
|
'''
|
|
|
:param str collection_name: name on the collection for which the schema will be set.
|
|
@@ -132,7 +132,7 @@ class MongodbHandler:
|
|
|
"Parameter 'key' must be one of these values: 1, -1, '2d', 'geoHaystack', '2dsphere', 'hashed', 'text' "
|
|
|
assert(isinstance(direction, str)),\
|
|
|
"Parameter 'direction' must be a string type"
|
|
|
-
|
|
|
+
|
|
|
self._database[collection_name].create_index([(key, direction)], name=key)
|
|
|
|
|
|
|
|
@@ -152,7 +152,7 @@ class MongodbHandler:
|
|
|
"Parameter 'validation_level' must be a string type"
|
|
|
assert(isinstance(validation_action, str)),\
|
|
|
"Parameter 'validation_action' must be a string type"
|
|
|
-
|
|
|
+
|
|
|
parse_obj = ParseJsonSchema(schema_paths=schema_path)
|
|
|
|
|
|
schema = parse_obj.read_schema_and_parse_for_mongodb(schema_path)
|