@@ -102,21 +102,24 @@ def count(self, **kwargs: Any) -> int:
102102 kwargs ["filter" ] = {}
103103 return len (self .collection .find (** kwargs ))
104104
105- def insert (self , content : bytes , filename : str , metadata : dict = {} ) -> None :
105+ def insert (self , data : list ) -> None :
106106 """Add the given entries to the underlying database.
107107
108108 Warning:
109109 No validation is performed on the incoming data.
110110
111111 Arguments:
112- content: The file content to add to gridfs.
113- filename: The filename of the added content.
114- metadata: extra metadata to add to the gridfs entry.
112+ data: a list of dictionaries. Each dictionary contains the data belonging to one file.
113+ These dictionaries contain the fields:
114+ data: The file content to add to gridfs.
115+ filename: The filename of the added content.
116+ metadata: extra metadata to add to the gridfs entry.
115117 """
116- self .collection .put (content , filename = filename , metadata = metadata )
118+ for entry in data : # todo check whether I can insert multiple files in one go.
119+ self .collection .put (** entry )
117120
118121 def handle_query_params (
119- self , params : Union [SingleEntryQueryParams , PartialDataQueryParams ]
122+ self , params : Union [SingleEntryQueryParams , PartialDataQueryParams ] # type: ignore[override]
120123 ) -> Dict [str , Any ]:
121124 """Parse and interpret the backend-agnostic query parameter models into a dictionary
122125 that can be used by MongoDB.
@@ -373,7 +376,7 @@ def insert(self, data: List[EntryResource]) -> None:
373376 self .collection .insert_many (data )
374377
375378 def handle_query_params (
376- self , params : Union [EntryListingQueryParams , SingleEntryQueryParams ]
379+ self , params : Union [EntryListingQueryParams , SingleEntryQueryParams ] # type: ignore[override]
377380 ) -> Dict [str , Any ]:
378381 """Parse and interpret the backend-agnostic query parameter models into a dictionary
379382 that can be used by MongoDB.
0 commit comments