From 7fbb830ec72d0d828e4422501532dc36a90deb19 Mon Sep 17 00:00:00 2001 From: Melanie Ballard Date: Mon, 16 Jun 2025 16:44:23 -0400 Subject: [PATCH 1/5] DOCSP-41784 add support for explicit resource management note where applicable resources are declared --- source/connect/connection-options/csot.txt | 2 ++ source/connect/mongoclient.txt | 2 ++ source/crud/transactions.txt | 2 ++ source/crud/transactions/transaction-core.txt | 4 +++- source/includes/explicit-resource-management.rst | 9 +++++++++ source/monitoring-and-logging/change-streams.txt | 2 ++ 6 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 source/includes/explicit-resource-management.rst diff --git a/source/connect/connection-options/csot.txt b/source/connect/connection-options/csot.txt index 3f97e5e9c..b23b37e75 100644 --- a/source/connect/connection-options/csot.txt +++ b/source/connect/connection-options/csot.txt @@ -195,6 +195,8 @@ adjust cursor handling by configuring either the cursor lifetime or cursor iteration mode if needed. To configure the mode, set the ``timeoutMode`` option to ``cursorLifetime``, which is the default, or ``iteration``. +.. include:: /includes/explicit-resource-management.rst + Cursor Lifetime Mode ~~~~~~~~~~~~~~~~~~~~ diff --git a/source/connect/mongoclient.txt b/source/connect/mongoclient.txt index f1b27a261..11ece0566 100644 --- a/source/connect/mongoclient.txt +++ b/source/connect/mongoclient.txt @@ -108,6 +108,8 @@ with behavior compatible with the specified API version. The following code shows how you can specify the connection string and the {+stable-api+} client option when connecting to a MongoDB deployment on Atlas and verify that the connection is successful: + +.. include:: /includes/explicit-resource-management.rst .. literalinclude:: /code-snippets/connection/stable-api-connect.js :language: javascript diff --git a/source/crud/transactions.txt b/source/crud/transactions.txt index 4a82050d4..18efe9641 100644 --- a/source/crud/transactions.txt +++ b/source/crud/transactions.txt @@ -159,6 +159,8 @@ You must perform the following steps when using this API: The following code demonstrates how to perform a transaction by using the Core API: +.. include:: /includes/explicit-resource-management.rst + .. literalinclude:: /code-snippets/transactions/txn-api-examples.js :language: javascript :emphasize-lines: 2,4,10,16,20,24,26 diff --git a/source/crud/transactions/transaction-core.txt b/source/crud/transactions/transaction-core.txt index bf8d3714e..c4ef5d60c 100644 --- a/source/crud/transactions/transaction-core.txt +++ b/source/crud/transactions/transaction-core.txt @@ -148,6 +148,8 @@ This example code performs a transaction through the following actions: :start-after: start placeOrder :end-before: end placeOrder +.. include:: /includes/explicit-resource-management.rst + .. _nodejs-transaction-example-payment-result: Transaction Results @@ -165,7 +167,7 @@ order ``_id`` appended to the orders field: "_id": 98765, "orders": [ "61dc..." - ] + ] } The ``inventory`` collection contains updated quantities for the diff --git a/source/includes/explicit-resource-management.rst b/source/includes/explicit-resource-management.rst new file mode 100644 index 000000000..1041494a9 --- /dev/null +++ b/source/includes/explicit-resource-management.rst @@ -0,0 +1,9 @@ +..note:: Explicit Resource Management + + Since v6.9, the {+driver-long+} now natively supports explicit resource + management for ``MongoClient``, ``ClientSession``, ``ChangeStreams``, and + cursors. To learn how to use explicit resource management, see + the `v6.9 Release Notes + `__ on + GitHub. It is important to note that this is an experimental feature and + subject to change. \ No newline at end of file diff --git a/source/monitoring-and-logging/change-streams.txt b/source/monitoring-and-logging/change-streams.txt index baeb054da..d6734ad91 100644 --- a/source/monitoring-and-logging/change-streams.txt +++ b/source/monitoring-and-logging/change-streams.txt @@ -136,6 +136,8 @@ the ``insertDB`` database and prints change events as they occur: :language: javascript :linenos: +.. include:: /includes/explicit-resource-management.rst + When you run this code and then make a change to the ``haikus`` collection, such as performing an insert or delete operation, you can see the change event document printed in your terminal. From 5f587f5a941ab291cd14e3a94df10096c6f435e2 Mon Sep 17 00:00:00 2001 From: Melanie Ballard Date: Mon, 16 Jun 2025 16:51:12 -0400 Subject: [PATCH 2/5] DOCSP-41784 fix note format --- source/includes/explicit-resource-management.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/includes/explicit-resource-management.rst b/source/includes/explicit-resource-management.rst index 1041494a9..b90d3c66d 100644 --- a/source/includes/explicit-resource-management.rst +++ b/source/includes/explicit-resource-management.rst @@ -1,4 +1,4 @@ -..note:: Explicit Resource Management +.. note:: Explicit Resource Management Since v6.9, the {+driver-long+} now natively supports explicit resource management for ``MongoClient``, ``ClientSession``, ``ChangeStreams``, and From 1ca7bfa2521565037be6b649c67b91ba04845dd8 Mon Sep 17 00:00:00 2001 From: Melanie Ballard Date: Tue, 17 Jun 2025 09:44:43 -0400 Subject: [PATCH 3/5] DOCSP-41784 change to tip and move pages around --- source/connect/connection-options/csot.txt | 2 -- source/crud/query/cursor.txt | 2 ++ source/includes/explicit-resource-management.rst | 13 ++++++------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/source/connect/connection-options/csot.txt b/source/connect/connection-options/csot.txt index b23b37e75..3f97e5e9c 100644 --- a/source/connect/connection-options/csot.txt +++ b/source/connect/connection-options/csot.txt @@ -195,8 +195,6 @@ adjust cursor handling by configuring either the cursor lifetime or cursor iteration mode if needed. To configure the mode, set the ``timeoutMode`` option to ``cursorLifetime``, which is the default, or ``iteration``. -.. include:: /includes/explicit-resource-management.rst - Cursor Lifetime Mode ~~~~~~~~~~~~~~~~~~~~ diff --git a/source/crud/query/cursor.txt b/source/crud/query/cursor.txt index 2abaaa62b..cab9d7d2a 100644 --- a/source/crud/query/cursor.txt +++ b/source/crud/query/cursor.txt @@ -170,6 +170,8 @@ and the {+mdb-server+}: :start-after: start close cursor example :end-before: end close cursor example +.. include:: /includes/explicit-resource-management.rst + Abort ~~~~~ diff --git a/source/includes/explicit-resource-management.rst b/source/includes/explicit-resource-management.rst index b90d3c66d..06f958504 100644 --- a/source/includes/explicit-resource-management.rst +++ b/source/includes/explicit-resource-management.rst @@ -1,9 +1,8 @@ -.. note:: Explicit Resource Management +.. tip:: Explicit Resource Management - Since v6.9, the {+driver-long+} now natively supports explicit resource - management for ``MongoClient``, ``ClientSession``, ``ChangeStreams``, and - cursors. To learn how to use explicit resource management, see - the `v6.9 Release Notes + As of v6.9, the {+driver-short+} supports explicit resource management for + ``MongoClient``, ``ClientSession``, ``ChangeStreams``, and cursors. This is + an experimental feature and subject to change. To learn how to use explicit + resource management, see the `v6.9 Release Notes `__ on - GitHub. It is important to note that this is an experimental feature and - subject to change. \ No newline at end of file + GitHub. \ No newline at end of file From ead861cb859d3f927345294613fcc1cc68578acd Mon Sep 17 00:00:00 2001 From: Melanie Ballard Date: Tue, 17 Jun 2025 11:07:39 -0400 Subject: [PATCH 4/5] DOCSP-41784 reword tip for clarity --- source/includes/explicit-resource-management.rst | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/source/includes/explicit-resource-management.rst b/source/includes/explicit-resource-management.rst index 06f958504..393b0e06b 100644 --- a/source/includes/explicit-resource-management.rst +++ b/source/includes/explicit-resource-management.rst @@ -1,8 +1,7 @@ .. tip:: Explicit Resource Management - As of v6.9, the {+driver-short+} supports explicit resource management for - ``MongoClient``, ``ClientSession``, ``ChangeStreams``, and cursors. This is - an experimental feature and subject to change. To learn how to use explicit - resource management, see the `v6.9 Release Notes - `__ on - GitHub. \ No newline at end of file + The {+driver-short+} natively supports explicit resource management for + ``MongoClient``, ``ClientSession``, ``ChangeStreams``, and cursors. This + feature is experimental and subject to change. To learn how to use explicit + resource management, see the `v6.9 Release Notes. + `__ \ No newline at end of file From 5f83efc08d410646e00f63d68fbd0a12b3497631 Mon Sep 17 00:00:00 2001 From: Melanie Ballard Date: Fri, 20 Jun 2025 09:13:23 -0400 Subject: [PATCH 5/5] DOCSP-41784 update backport file and move tips to below code examples --- .backportrc.json | 3 +++ source/connect/mongoclient.txt | 4 ++-- source/crud/transactions.txt | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.backportrc.json b/.backportrc.json index 1df6bbc2b..65257f2fc 100644 --- a/.backportrc.json +++ b/.backportrc.json @@ -5,6 +5,9 @@ // the branches available to backport to "targetBranchChoices": [ "master", + "v6.17", + "v6.16", + "v6.15", "v6.14", "v6.13", "v6.12", diff --git a/source/connect/mongoclient.txt b/source/connect/mongoclient.txt index 11ece0566..5e56b757c 100644 --- a/source/connect/mongoclient.txt +++ b/source/connect/mongoclient.txt @@ -108,8 +108,6 @@ with behavior compatible with the specified API version. The following code shows how you can specify the connection string and the {+stable-api+} client option when connecting to a MongoDB deployment on Atlas and verify that the connection is successful: - -.. include:: /includes/explicit-resource-management.rst .. literalinclude:: /code-snippets/connection/stable-api-connect.js :language: javascript @@ -121,6 +119,8 @@ verify that the connection is successful: Call the ``MongoClient.connect()`` method explicitly if you want to verify that the connection is successful. +.. include:: /includes/explicit-resource-management.rst + To learn more about the {+stable-api+} feature, see the :ref:`{+stable-api+} page `. diff --git a/source/crud/transactions.txt b/source/crud/transactions.txt index 18efe9641..8a6d2ec5b 100644 --- a/source/crud/transactions.txt +++ b/source/crud/transactions.txt @@ -159,8 +159,6 @@ You must perform the following steps when using this API: The following code demonstrates how to perform a transaction by using the Core API: -.. include:: /includes/explicit-resource-management.rst - .. literalinclude:: /code-snippets/transactions/txn-api-examples.js :language: javascript :emphasize-lines: 2,4,10,16,20,24,26 @@ -183,6 +181,8 @@ the Core API: const session = client1.startSession(); client2.db('myDB').collection('myColl').insertOne({ name: 'Jane Eyre' }, { session }); +.. include:: /includes/explicit-resource-management.rst + To see a fully runnable example that uses this API, see the :ref:`node-usage-core-txn` usage example.