Skip to content

Commit

Permalink
fix filter to dict obj
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandredevely committed Jun 26, 2024
1 parent 517e3cc commit ef9fc34
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions oc/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,15 @@ def stringify( self, collectionresult:list ):
"""
if isinstance( collectionresult, list):
for obj in collectionresult:
if isinstance( obj.get('_id'), bson.objectid.ObjectId ):
# should always True
if hasattr( obj['_id'], '__str__') and callable(obj['_id'].__str__):
obj['_id'] = obj['_id'].__str__()
if isinstance( obj.get('date'), datetime.datetime) :
# should always True
if hasattr( obj['date'], '__str__') and callable(obj['date'].__str__):
obj['date'] = obj['date'].__str__()
if isinstance( obj, dict) :
if isinstance( obj.get('_id'), bson.objectid.ObjectId ):
# should always True
if hasattr( obj['_id'], '__str__') and callable(obj['_id'].__str__):
obj['_id'] = obj['_id'].__str__()
if isinstance( obj.get('date'), datetime.datetime) :
# should always True
if hasattr( obj['date'], '__str__') and callable(obj['date'].__str__):
obj['date'] = obj['date'].__str__()
return collectionresult

def set_document_value_in_collection(self, databasename:str, collectionname:str, key:str, value:dict):
Expand Down

0 comments on commit ef9fc34

Please sign in to comment.