Mongoose version upgrade

My vue js and node js based microservice application uses mongodb version- 5.0 currently. The mongoose version is defined in package.json- mongoose": “^5.13.14”.
The database required to be upgraded to version to 6.0. Accordingly I need to upgrade mongoose to compatible version of 6.5.0. or 7.0.0. Pease let me know if there any more changes required from application point of view

1 Like

Hello @vibhuti_sharan,

You can read the version compatibility and the migration guide of Mongoose version 6.

Similarly read the release notes and upgrade to version 6 guide of MongoDB.

2 Likes

Hello, thank you for sharing.
Weirdly, the upgraded mongodb version- ```6.0.14-11’ is working with existing mongoose": “^5.13.14”. Not sure how the application is picking the version.`

1 Like

Hi @vibhuti_sharan,

The compatibility depends on available features, modules, functions, or methods, of a particular library Mongoose, so you have to check the migration guide, and what they have upgraded/changed because of the dependency on MongoDB’s new version. If you find anything related to your implemented features in your code then you can update otherwise it is ok.

3 Likes

Thanks for those links, you made my day.

1 Like

Even if you upgrade MongoDB to version 6.x, you can still use Mongoose versions below 6.x.
However, if you update Mongoose, keep in mind that Mongoose is a wrapper around the MongoDB Node.js driver.
This means that updating Mongoose will also update underlying Node.js driver version. Therefore, you should carefully check all changes between the current and new versions of both Mongoose and the Node.js driver.
Some APIs may be deprecated, some types might change, and new features could be added. it’s crucial to evaluate these changes and select the best version that fits you server’s requirements.

For example, I needed the ability to return data outside of the withTransaction() helper callback, which is supported starting from the 6.x version of the MongoDB Node.js driver. As a result, I chose Mongoose 8.x, which uses a driver version higher than 6.x.
Additionally, if you’re using mongodb-memory-server for testing purposes, make sure to update its binary version to match the database version you’re using.