# Migrating from contrib mongodb2 node to contrib mongodb

**URL:** <https://discourse.nodered.org/t/migrating-from-contrib-mongodb2-node-to-contrib-mongodb/33634>\
**Category:** General\
**Created:** [1 October 2020 15:52 UTC](https://discourse.nodered.org/t/migrating-from-contrib-mongodb2-node-to-contrib-mongodb/33634 "2020-10-01T15:52:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dennishvo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dennishvo/32/2896_2.png) [@dennishvo](https://discourse.nodered.org/u/dennishvo)\
**Post date:** [1 October 2020 15:52 UTC](https://discourse.nodered.org/t/migrating-from-contrib-mongodb2-node-to-contrib-mongodb/33634/1 "2020-10-01T15:52:48Z")

</div>

I have been using node-red-contrib-mongodb2 but it's poorly supported. I'm in the process of migrating to node-red-node-mongodb, and I have two challenges:

1. I use logic that tests for the outcome of updates and inserts (e.g. possibility of key not found or duplicate key), but I don't see how to do that with the mongodb node. Are exceptions thrown? What is recommended?

2. I'm currently able to do a partial update of a document, e.g. there are 10 fields and I want to change 2 of them without eliminating the others. I can do that in mongodb2, but it isn't obvious how to do it with mongodb.

Thanks!

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [1 October 2020 20:24 UTC](https://discourse.nodered.org/t/migrating-from-contrib-mongodb2-node-to-contrib-mongodb/33634/2 "2020-10-01T20:24:51Z")

</div>

I can't help you with this but I've edited the title a better describe what you need help with. When seeing the title I figured it's about migrating data from a new Mongodb version to an older one which would not fit the forum and would possibly be difficult (I've never used mongodb myself).

---

<div class="post-metadata">

**Author:** ![dennishvo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dennishvo/32/2896_2.png) [@dennishvo](https://discourse.nodered.org/u/dennishvo)\
**Post date:** [2 October 2020 06:25 UTC](https://discourse.nodered.org/t/migrating-from-contrib-mongodb2-node-to-contrib-mongodb/33634/3 "2020-10-02T06:25:38Z")

</div>

Thanks for clarifying the title. The connection string that I had been using with mongodb2 to connect to MongoDB version 3.6 running on Atlas would not work on version 4.2 (also on Atlas). I did some experiments with node-red-node-mongodb 0.2.1 and I got it to connect to 4.2. However, I soon discovered that the difference in behavior between those two packages was going to require a lot of recoding. The two challenges I mentioned above caused me to double back.

Ultimately, I reached a tech at Atlas who was able to conjure up a connection string that enabled mongodb2 to connect to version 4.2. The new string makes use of a replicaSet parameter. So I guess that's problem solved. I can finally upgrade my database.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [16 October 2020 06:25 UTC](https://discourse.nodered.org/t/migrating-from-contrib-mongodb2-node-to-contrib-mongodb/33634/4 "2020-10-16T06:25:50Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
