I am new to MongoDB, I’m using the Python driver to work with the database. I’d like to be able to implement optimistic concurrency and was wondering if MongoDB has some built in concurrency checking. I tried to test it by creating a database with a single table with a single entry and do the following
- Read the table twice for the same record and store the result into 2 separate objects
- Update the same field in each object with different values
- Perform 2 update_one() operations
When I run this the second write overwrites the first so it appears to me there is no checking by MongoDB. Can anyone direct me on what I’m doing wrong? Here is a screenshot of the code: