Spaces:
Running
Running
added dream role and fixed interem role bug
Browse files
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 |
-
|
174 |
-
|
|
|
|
|
|
|
|
|
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 |
|