File tree 1 file changed +8
-6
lines changed
fastapi_crudrouter_mongodb/core/models
1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -57,20 +57,22 @@ def convert_to(self, model: BaseModel):
57
57
new_model = {}
58
58
for field in dump_model :
59
59
value = dump_model [field ]
60
- if ( value is not None ) :
61
- if ( isinstance (value , list ) ):
60
+ if value is not None :
61
+ if isinstance (value , list ):
62
62
value = self ._convert_list (value )
63
- new_model [field ] = value if type (value ) is not ObjectId else str (value )
64
-
63
+ new_model [field ] = value if type (value ) is not ObjectId else str (value )
64
+
65
65
return model (** new_model )
66
66
67
67
def _convert_list (self , list_to_convert : list ):
68
- if ( isinstance (list_to_convert [0 ], dict ) ):
68
+ if isinstance (list_to_convert [0 ], dict ):
69
69
new_list = []
70
70
for sub_object in list_to_convert :
71
71
for sub_field in sub_object :
72
72
sub_value = sub_object [sub_field ]
73
- sub_object [sub_field ] = sub_value if type (sub_value ) is not ObjectId else str (sub_value )
73
+ sub_object [sub_field ] = (
74
+ sub_value if type (sub_value ) is not ObjectId else str (sub_value )
75
+ )
74
76
new_list .append (sub_object )
75
77
return new_list
76
78
return list_to_convert
You can’t perform that action at this time.
0 commit comments