BPA v4.1.2 includes an upgrade to MongoDB v7, as MongoDB v5 is approaching end of life. This document provides details for upgrading the MongoDB version in microservices.
Update the following package versions in microservices:
The following variables are deprecated in MongoDB v7:
Replace ssl with tls as shown in the following example:
if (process.env.MONGO_SSL == "true") {
//options.ssl = true;
options.tls = true;
options.tlsAllowInvalidCertificates = true;
}
Callback in MongoDB queries has been deprecated in MongoDB v7. The updated query displays in green below.
After performing the delete query, the response variable should use deletedCount in place of n (e.g., replace result.n with result.deletedCount).
After performing the update operation, the response variable should use modifiedCount in place of n/nModified (e.g., Replace devices.n / devices.nModified to devices.modifiedCount in as shown below).
Replace the db.addUser() function with db.command(createUse: “username”) as shown in the following example.
Update the following methods deprecated in MongoDB v7 as indicated below.
Deprecated Method | New Method |
---|---|
update | updateOne or updateMany |
remove | delete or deleteMany |
count | countDocuments |
findOneAndRemove | findOneAndDelete |
In MongoDB v7, the GridFSBucket class is used to interact with GridFS, a specification for storing and retrieving large files. The GridFSBucket class provides methods to upload, download, and manage files in GridFS.
Replace gridfs-stream by importing GridFSBucket from MongoDB. Refer to the following images to view the changes.
Revision | Publish Date | Comments |
---|---|---|
1.0 |
23-Sep-2025
|
Initial Release |