'Unable to update and delete documents after converting standalone MongoDb instance to Replica Set
I was able to update and remove documents perfectly with the standalone instance. In order to enable transactions,I converted it into replica set. mongodb://localhost:27017/?replicaSet=rs0&readPreference=primary is the url I use to connect to mongodb.
Below are transaction options I use. exports.transactionOptions = { readPreference: 'primary', readConcern: { level: 'local' }, writeConcern: { w: 'majority' } };
I am trying to execute the below query to update a Post document.
post.postModel.updateOne({"_id": postId },{$set:payload}, { runValidators: true }).session(session)
Although in result I get the modifiedCount and matchedCount as 1, but the document never gets updated in the collection.
I have a similar issue with remove and delete as well. The result of the query is positive but I see no changes in the collection.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
