[docs]classMongoDBDatabase(Database):""" An adapter for MongoDB databases. The LinkML-Store Database abstraction combines mongodb Client and Database. """_native_client:MongoClient=None_native_db=Nonecollection_class=MongoDBCollection
[docs]defquery(self,query:Query,**kwargs)->QueryResult:ifquery.from_table:collection=self.get_collection(query.from_table)returncollection.query(query,**kwargs)else:raiseNotImplementedError(f"Querying without a table is not supported in {self.__class__.__name__}")
[docs]defimport_database(self,location:str,source_format:Optional[str]=None,**kwargs):""" Import a database from a file or location. :param location: location of the file :param source_format: source format :param kwargs: additional arguments """ifsource_format==Format.DUMP_MONGODB.valueorsource_format==Format.DUMP_MONGODB:import_mongodb(self.handle,location,drop=True)else:super().import_database(location,source_format=source_format,**kwargs)