Ticket: Durable Writes

hi all,
unable to resolve TODO: Durable Writes # Use a more durable Write Concern for this operation test case.
help me out pls.

@nayamama - hi can you help me out with this ticket.


Did you check this post? Or you could narrow down your question, such as not sure correct syntax or providing corresponding error message.

Q Yang

thanks Yang, The question is the correct syntax for the write durable in todo : user management->Durable write
i am using
find_result = db.users.find_one({“email”:email},{"_id":0,“email”:1})
if find_result != ‘null’ :
db.users.insert_one({“name”: name, “email”:email,‘password’:hashedpw})
return {“success”:True}
except DuplicateKeyError:
return {“error”: “A user with the given email already exists.”}
however the status shows.

I have also verified in altas that there are no duplicate mail ids in DB as per test case.

First, this TODO is about WriteConcern. But you did not implement it in the code. The post I mentioned above gives the right syntax.

Second, if you check the index of users collection, the email field is defined unique index. Therefore, it is not possible to find duplicate emails in collection, which is handled by server before inserting a document.

If you have interest, you could read the python exception handling document. You will find why we use “try…except”. Back to this ticket, checking the duplicate email is handled by unique index mechanism, handling exception is done by python itself. The only thing you need to write is just inserting a document with required WriteConcern.

Hope it could help.

Q Yang

1 Like

It helped. Thanks a lot.