MongoDB 3.2 - updateOne () returning error

Dear Team,

We have one of our Application running on MongoDB 3.2 community version.

We have one requirement to update documents where we have to search documents where response is one document and it has RESOLUTION element with some value, to create a another document in same main document having resolution.paramters.RESOLUTION structure. With below query I am getting error. Please help.

orderhub:SECONDARY> db.tasks.updateOne( { $and: [{“response.RESOLUTION”: {$exists: true}} , {“response.RESOLUTION”:“RESUBMIT”}]}, {$set: {“resolution” : {“parameters” : {“RESOLUTION” : “RESUBMIT”}}}})

2022-03-01T16:52:06.510+0530 E QUERY [thread1] TypeError: err.hasWriteErrors is not a function :
DBCollection.prototype.updateOne@src/mongo/shell/crud_api.js:519:13

Hi @Amit_Mallick

A couple of things I noticed:

First is that you’re connected to a SECONDARY. Doing any write requires you to connect to the PRIMARY instead. Please try to connect using the proper replica set connection string instead of directly connecting to a single server.

Second is that MongoDB 3.2 is quite old and unsupported by now. In fact, it was out of support since September 2018. Thus, more recent tools, drivers, etc. may not work as expected anymore due to the outdated server version. You might want to consider upgrading to a more recent version of MongoDB not only for support purposes, but also for many improvements and bugfixes in newer versions.

Having said that, the path to upgrade is unfortunately quite involved since the server you’re using is so far behind. You would need to upgrade: 3.2 → 3.4 → 3.6 → 4.0 → 4.2 (the oldest supported version). Depending on your deployment size, it might be easier to do a mongodump & mongorestore into a new servers.

Best regards
Kevin

2 Likes