File tree 1 file changed +7
-6
lines changed
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]):
197
197
return nested_fields
198
198
199
199
200
- def create_nested_pipeline (model : Type [BaseModel ], prefix = "" ):
200
+ def create_nested_pipeline (model : Type [BaseModel ], prefix = "" , pipeline = None ):
201
201
logger .debug (f"Creating nested pipeline for model: { model .__name__ } , prefix: { prefix } " )
202
202
nested_fields = get_nested_fields (model )
203
203
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
+ }
208
209
209
210
for field_name , field_type in model .__fields__ .items ():
210
211
if field_name == "timestamp" :
@@ -240,7 +241,7 @@ def create_nested_pipeline(model: Type[BaseModel], prefix=""):
240
241
match_conditions [full_mongo_field_name ] = {"$exists" : True , "$ne" : []}
241
242
else :
242
243
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
244
245
)
245
246
pipeline [field_name ] = nested_pipeline
246
247
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