File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -197,14 +197,15 @@ def get_nested_fields(model: Type[BaseModel]):
197197 return nested_fields
198198
199199
200- def create_nested_pipeline (model : Type [BaseModel ], prefix = "" ):
200+ def create_nested_pipeline (model : Type [BaseModel ], prefix = "" , pipeline = None ):
201201 logger .debug (f"Creating nested pipeline for model: { model .__name__ } , prefix: { prefix } " )
202202 nested_fields = get_nested_fields (model )
203203 match_conditions = {}
204- pipeline = {
205- "_id" : False ,
206- "timestamp" : "$timestamp" ,
207- }
204+ if pipeline is None :
205+ pipeline = {
206+ "_id" : False ,
207+ "timestamp" : "$timestamp" ,
208+ }
208209
209210 for field_name , field_type in model .__fields__ .items ():
210211 if field_name == "timestamp" :
@@ -240,7 +241,7 @@ def create_nested_pipeline(model: Type[BaseModel], prefix=""):
240241 match_conditions [full_mongo_field_name ] = {"$exists" : True , "$ne" : []}
241242 else :
242243 nested_pipeline , nested_match = create_nested_pipeline (
243- nested_fields [field_name ], f"{ field_name } ."
244+ nested_fields [field_name ], f"{ full_mongo_field_name } ." , pipeline
244245 )
245246 pipeline [field_name ] = nested_pipeline
246247 match_conditions .update ({f"{ field_name } .{ k } " : v for k , v in nested_match .items ()})
You can’t perform that action at this time.
0 commit comments