Closed igor-levkov closed 6 years ago
Interesting issue... upgrading to mongodb 3 should be easy, because the api is almost the same.
Maybe I will have some time to work on it over the weekend, but I cannot promise. If anyone reading this wants to do the work, I will be happy to accept a pull-request (let me know with a comment before you begin working). I see that they have complicated the MongoClient.connect
operation - it now returns a MongoClient object that can be used to create a Db object (the old MongoClient.connect
operation returned the Db directly). However this should easy to handle.
Also, maybe the name node-red-contrib-mongodb2
will become confusing. Actually, the "2" here does not symbolise "mongodb native version 2". I just added it to avoid confusion with the node-red-node-mongodb
.
I think I will open a node-red-contrib-mongodb-native project for mongodb3 support and above.
Furthermore, I don't know if mongodb3 provides new api functions (or is it just the old functions with more options?). If so, this may take some time to support, depending on each operation.
If you think of any issue where mongodb3 may not be backward-compatible with mongodb2 (except for the MongoClient.connect
operation), please let me know.
Sorry, I don't have time to work on the issue this week. Maybe next one.
I created pull request. Not sure if changes must be kept in same repository. If you want any adjustments, please let me know, I will try to find time. I tested features I was interested in and looks good. Sure there will be bugs found in future.
Published with minor fixes: https://www.npmjs.com/package/node-red-contrib-mongodb3 .
I replaced all the var
s with const
s and let
s. I also fixed the regex that fetches the db name, in case there are query-params, i.e. the uri ends with things like '?replicaSet=...'.
I really don't get why they had to change API (from version 2 to version 3) and make us create a Db object in addition to the MongoClient object. Maybe they wanted to allow creating a single MongoClient connection, and use it to access multiple databases under the same host? This is such an uncommon use case...
Oh, and I didn't fully test the driver yet...
Do you have any plans to support mongodb native drive version 3?