Nattyboi commited on
Commit
e2a962e
·
1 Parent(s): 124c54c

added dream role and fixed interem role bug

Browse files
Files changed (1) hide show
  1. utils.py +6 -2
utils.py CHANGED
@@ -170,8 +170,12 @@ def create_questionaire(db_uri: str, db_name: str, collection_name: str, documen
170
  collection = db[collection_name]
171
 
172
  # Insert the document
173
- result = collection.insert_one(document)
174
- client.close()
 
 
 
 
175
 
176
  return str(result.inserted_id)
177
 
 
170
  collection = db[collection_name]
171
 
172
  # Insert the document
173
+ try:
174
+ result= collection.find_one_and_replace(filter={"user_id":document.get("user_id")},replacement=document)
175
+ except:
176
+ result = collection.insert_one(document)
177
+ finally:
178
+ client.close()
179
 
180
  return str(result.inserted_id)
181