|
| 1 | +.. _node-upgrade-driver: |
| 2 | + |
| 3 | +======================= |
| 4 | +Upgrade Driver Versions |
| 5 | +======================= |
| 6 | + |
| 7 | +.. contents:: On this page |
| 8 | + :local: |
| 9 | + :backlinks: none |
| 10 | + :depth: 2 |
| 11 | + :class: singlecol |
| 12 | + |
| 13 | +Overview |
| 14 | +-------- |
| 15 | + |
| 16 | +On this page, you can learn about any changes you might need to make to |
| 17 | +your application to upgrade your driver to a new version without loss of |
| 18 | +functionality. |
| 19 | + |
| 20 | +Before you upgrade, perform the following actions: |
| 21 | + |
| 22 | +- Ensure the new driver version is compatible with the {+mdb-server+} version |
| 23 | + your application connects to and the version of Node.js that your |
| 24 | + application runs on. See the :ref:`<node-compatibility>` |
| 25 | + page for this information. |
| 26 | +- Address any breaking changes between the version of the driver |
| 27 | + your application currently uses and your planned upgrade version in the |
| 28 | + :ref:`<node-breaking-changes>` section of this guide. To learn |
| 29 | + more about the {+mdb-server+} release compatibility changes, see the |
| 30 | + :ref:`<node-server-support-changes>` section. |
| 31 | + |
| 32 | +.. tip:: |
| 33 | + |
| 34 | + You can minimize the amount of changes that you need to make to your |
| 35 | + application when upgrading driver versions by using the |
| 36 | + :ref:`{+stable-api+} <nodejs-stable-api>`. |
| 37 | + |
| 38 | +.. _node-breaking-changes: |
| 39 | + |
| 40 | +Breaking Changes |
| 41 | +---------------- |
| 42 | + |
| 43 | +A breaking change is a modification in a convention or behavior in |
| 44 | +a specific version of the driver that may prevent your application from |
| 45 | +working as expected. |
| 46 | + |
| 47 | +The breaking changes in this section are categorized by the major |
| 48 | +version releases that introduced them. When upgrading driver versions, |
| 49 | +address all the breaking changes between your current version and the |
| 50 | +planned upgrade version. For example, if you are upgrading the driver |
| 51 | +from v3.x to v5.x, address all breaking changes listed under v4.x and |
| 52 | +v5.x. |
| 53 | + |
| 54 | +.. _node-breaking-changes-v5.x: |
| 55 | + |
| 56 | +Version 5.x Breaking Changes |
| 57 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 58 | + |
| 59 | +- Driver versions 5.x are not compatible with Node.js |
| 60 | + v12 or earlier. If you want to use this version of the driver, You must |
| 61 | + use Node.js v14.20.1 or greater. |
| 62 | + |
| 63 | +- The driver removes support for callbacks in favor of a promise-based API. |
| 64 | + The following list provides some strategies for callback users to adopt this |
| 65 | + version: |
| 66 | + |
| 67 | + - Migrate to the promise-based API (recommended) |
| 68 | + - Use the promise-based API and ``util.callbackify`` |
| 69 | + - Add ``mongodb-legacy`` to continue using callbacks |
| 70 | + |
| 71 | + For more information about these strategies, see |
| 72 | + `the v5.0 changelog <https://github.com/mongodb/node-mongodb-native/blob/main/etc/notes/CHANGES_5.0.0.md#optional-callback-support-migrated-to-mongodb-legacy>`__. |
| 73 | + |
| 74 | +- The driver removes support for the ``Collection.insert()``, |
| 75 | + ``Collection.update()``, and ``Collection.remove()`` helper methods. |
| 76 | + The following list provides instructions on how to replace the |
| 77 | + functionality of the removed methods: |
| 78 | + |
| 79 | + - Migrate from ``Collection.insert()`` to ``insertOne()`` or ``insertMany()`` |
| 80 | + - Migrate from ``Collection.update()`` to ``updateOne()`` or ``updateMany()`` |
| 81 | + - Migrate from ``Collection.remove()`` to ``deleteOne()`` or ``deleteMany()`` |
| 82 | + |
| 83 | +- The driver no longer includes AWS SDK modules by default. |
| 84 | + |
| 85 | +- The driver no longer automatically imports the ``bson-ext`` package. |
| 86 | + |
| 87 | +- The driver removes support for custom ``Promise`` libraries. The driver no |
| 88 | + longer supports the ``promiseLibrary`` option of ``MongoClient`` and the ``Promise.set`` |
| 89 | + export that allows specifying a custom ``Promise`` library. |
| 90 | + |
| 91 | +- The driver removes support for the ``Collection.mapReduce()`` helper. |
| 92 | + |
| 93 | +- The ``BulkWriteResult`` type no longer has the publicly enumerable |
| 94 | + ``result`` property. |
| 95 | + |
| 96 | +- The following types, options, and methods have been removed: |
| 97 | + |
| 98 | + - ``BulkResult.lastOp()`` method |
| 99 | + - ``opTime`` property of ``BulkResult`` |
| 100 | + - ``BulkWriteOptions.keepGoing`` option |
| 101 | + - ``WriteConcernError.err()`` method |
| 102 | + - ``AddUserOptions.digestPassword`` option |
| 103 | + - Kerberos ``gssapiCanonicalizeHostName`` option |
| 104 | + - ``slaveOk`` options and method removed in favor of ``secondaryOk`` |
| 105 | + - ``ObjectID`` type removed in favor of ``ObjectId`` |
| 106 | + - ``AsyncIterator`` interface removed in favor of ``AsyncGenerator`` |
| 107 | + |
| 108 | +.. _node-breaking-changes-v4.x: |
| 109 | + |
| 110 | +Version 4.x Breaking Changes |
| 111 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 112 | + |
| 113 | +- Driver versions 4.x are not compatible with Node.js |
| 114 | + v12.8 or earlier. If you want to use this version of the driver, You must |
| 115 | + use Node.js v12.9 or greater. |
| 116 | + |
| 117 | +- ``Cursor`` types no longer extend ``Readable`` directly. |
| 118 | + |
| 119 | +- You cannot use a ``ChangeStream`` instance as an iterator after using |
| 120 | + it as an ``EventEmitter``. You also cannot do the reverse—using an |
| 121 | + ``EventEmitter`` instance as an iterator after using it as a ``ChangeStream``. |
| 122 | + |
| 123 | +- The following methods no longer accept a callback parameter: |
| 124 | + |
| 125 | + - ``Collection.find()`` |
| 126 | + - ``Collection.aggregate()`` |
| 127 | + - ``Db.aggregate()`` |
| 128 | + |
| 129 | +- The default value of the ``maxPoolSize`` connection option is now |
| 130 | + ``100``. |
| 131 | + |
| 132 | +- The driver no longer supports the ``gssapiServiceName`` Kerberos |
| 133 | + option. Users should use ``authMechanismProperties.SERVICE_NAME`` instead. |
| 134 | + |
| 135 | +- The driver no longer accepts non-boolean types, such as ``0`` or |
| 136 | + ``1``, for boolean options. |
| 137 | + |
| 138 | +- The ``db.collection`` type no longer accepts a callback. |
| 139 | + |
| 140 | +- The ``Db`` type is no longer an ``EventEmitter``. You can listen to |
| 141 | + any events directly from the ``MongoClient`` instance. |
| 142 | + |
| 143 | +- The driver removes support for the ``Collection.group()`` helper. |
| 144 | + |
| 145 | +- The driver no longer includes the deprecated ``GridStore`` API. |
| 146 | + |
| 147 | +For more information about these changes, see |
| 148 | +`the v4.0 changelog <https://github.com/mongodb/node-mongodb-native/blob/main/etc/notes/CHANGES_4.0.0.md>`__. |
| 149 | + |
| 150 | +.. _node-server-support-changes: |
| 151 | + |
| 152 | +Server Release Compatibility Changes |
| 153 | +------------------------------------ |
| 154 | + |
| 155 | +A server release compatibility change is a modification |
| 156 | +to the driver that discontinues support for a set of |
| 157 | +{+mdb-server+} versions. |
| 158 | + |
| 159 | +The driver discontinues support for a {+mdb-server+} version after it reaches |
| 160 | +end-of-life (EOL). |
| 161 | + |
| 162 | +To learn more about the MongoDB support for EOL products, |
| 163 | +see the `Legacy Support Policy <https://www.mongodb.com/support-policy/legacy>`__. |
| 164 | + |
| 165 | +Version 4.2 Server Release Support Changes |
| 166 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 167 | + |
| 168 | +- The v4.2 driver drops support for {+mdb-server+} v3.4 and earlier. |
| 169 | + To use the v4.2 driver, your {+mdb-server+} must be v3.6 or later. To learn |
| 170 | + how to upgrade your {+mdb-server+} to v3.6, follow the link that corresponds |
| 171 | + to your MongoDB deployment configuration: |
| 172 | + |
| 173 | + - :ref:`<3.6-upgrade-replica-set>` |
| 174 | + - :ref:`<3.6-upgrade-standalone>` |
| 175 | + - :ref:`<3.6-upgrade-sharded-cluster>` |
0 commit comments